Show Table of Contents
20.7.3. 为 Java Messaging Service (JMS) 客户配置服务器
属性
JMSXGroupID 用于为 JMS 客户识别消息组。如果您想发送包含不同消息的消息组到某个消费者,您可以对不同的消息设置相同的 JMSXGroupID:
Message message = ...
message.setStringProperty("JMSXGroupID", "Group-0");
producer.send(message);
message = ...
message.setStringProperty("JMSXGroupID", "Group-0");
producer.send(message);
第二个途径是设置 HornetQConnectonFactory 上的 autogroup 属性为 "true"。HornetQConnectionFactory 将选取一个随机的唯一消息组 ID。您可以这样在服务器配置文件(standalone.xml 和 domain.xml)里设置 autogroup 属性:
<connection-factory name="ConnectionFactory">
<connectors>
<connector-ref connector-name="netty-connector"/>
</connectors>
<entries>
<entry name="ConnectionFactory"/>
</entries>
<autogroup>true</autogroup>
</connection-factory>
除了上面两个途径以外,另外一个方法是通过连接工厂设置专有的消息组 ID。这将依次将通过这个连接工厂发送的所有消息的属性 JMSXGroupID 设置为指定的值。要在连接工厂上设置专有的消息组 ID,请编辑服务器配置文件(standalone.xml 和 domain.xml)里的 group-id 属性:
<connection-factory name="ConnectionFactory">
<connectors>
<connector-ref connector-name="netty-connector"/>
</connectors>
<entries>
<entry name="ConnectionFactory"/>
</entries>
<group-id>Group-0</group-id>
</connection-factory>

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.