이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 26. Message Grouping
Message groups are sets of messages that have the following characteristics:
- Messages in a message group share the same group id; that is, they have the same group identifier property (
JMSXGroupID
for JMS,_HQ_GROUP_ID
for HornetQ Core API). - Messages in a message group are always consumed by the same consumer, even if there are many consumers on a queue. They pin all messages with the same group id to the same consumer. If that consumer closes another consumer is chosen and will receive all messages with the same group id.
Message groups are useful when you want all messages for a certain value of the property to be processed serially by the same consumer.
An example might be orders for a certain stock. You may want orders for any particular stock to be processed serially by the same consumer. To do this you can create a pool of consumers (perhaps one for each stock), then set the stock name as the value of the _HQ_GROUP_ID property.
This will ensure that all messages for a particular stock will always be processed by the same consumer.
26.1. Using Core API 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The property name used to identify the message group is
"_HQ_GROUP_ID"
(or the constant MessageImpl.HDR_GROUP_ID
). Alternatively, you can set autogroup
to true on the SessionFactory
which will pick a random unique id.