此内容没有您所选择的语言版本。

Chapter 22. Message Grouping


A message group is a group of messages that share certain characteristics:

  • All messages in a message group are grouped under a common group id. This means that they can be identified with a common group property.
  • All messages in a message group are serially processed and consumed by the same consumer, irrespective of the number of customers on the queue. This means that a specific message group with a unique group id is always processed by one consumer when the consumer opens it. If the consumer closes the message group, then the entire message group is directed to another consumer in the queue.

Message groups are especially useful when there is a need for messages with a certain value of the property (group id) to be processed serially by a single consumer.

Important

Message grouping will not work as expected if the queue has paging enabled. Be sure to disable paging before configuring a queue for message grouping.

For information about configuring message grouping within a cluster of messaging servers, see Clustered Message Grouping in Part III, Configuring Multiple Messaging Systems.

22.1. Configuring Message Groups Using the Core API

The property _AMQ_GROUP_ID is used to identify a message group using the Core API on the client side. To pick a random unique message group identifier, you can also set the auto-group property to true on the SessionFactory.

22.2. Configuring Message Groups Using JMS

The property JMSXGroupID is used to identify a message group for Java Messaging Service (JMS) clients. If you wish to send a message group with different messages to one consumer, you can set the same JMSXGroupID for different messages.

Message message = ...
message.setStringProperty("JMSXGroupID", "Group-0");
producer.send(message);

message = ...
message.setStringProperty("JMSXGroupID", "Group-0");
producer.send(message);
Copy to Clipboard Toggle word wrap

An alternative approach is to use the one of the following attributes of the connection-factory to be used by the client: auto-group or group-id.

When auto-group is set to true, the connection-factory will begin to use a random unique message group identifier for all messages sent through it. You can use the management CLI to set the auto-group attribute.

/subsystem=messaging-activemq/server=default/connection-factory=RemoteConnectionFactory:write-attribute(name=auto-group,value=true)
Copy to Clipboard Toggle word wrap

The group-id attribute will set the property JMSXGroupID to the specified value for all messages sent through the connection factory. To set a specific group-id on the connection factory, use the management CLI.

/subsystem=messaging-activemq/server=default/connection-factory=RemoteConnectionFactory:write-attribute(name=group-id,value="Group-0")
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat