9.2. How to Enable Message Ordering Group

You can enable an ordering group either on a connection factory or on a producer:

9.2.1. Enabling Ordering Group on Producer

To enable the ordering group feature on producer, do the following:
  1. Add a JBossMessageProducer to your session:
    JBossMessageProducer producer=(JBossMessageProducer)session.createProducer(queue);
  2. Add the enableOrderingGroup method to set an ordering group:
    producer.enableOrderingGroup(String ogrpName) throws JMSException
    The method creates an ordering group; when the method is called, JBossMessageProducer sends messages on behalf of the ordering group. If you provide null as the method parameter, the ordering group is generated automatically. A new call to this method overrides the previous call.
  3. Optionally, you can add the disableOrderingGroup() method to disable the ordering group:
    public void disableOrderingGroup() throws JMSException
    When the method is called, JBossMessageProducer stops sending ordering group messages and resumes its default behavior.
An example is available in $EAPHOME/doc/examples/jboss-messaging-examples/ordering-group/ in the class OrderingGroupExample.java (src/org/jboss/example/jms/ordering/OrderingGroupExample.java). Note that the example is delivered as part of the jboss-eap-docs archive.