try
{
conn = cf.createConnection();
Session producerSess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
JBossMessageProducer producer = (JBossMessageProducer)producerSess.createProducer(queue1);
conn.start();
TextMessage tmNormal1 = producerSess.createTextMessage("NoOrdering-1");
producer.send(tmNormal1, DeliveryMode.PERSISTENT, 6, Message.DEFAULT_TIME_TO_LIVE);
TextMessage tmNormal2 = producerSess.createTextMessage("NoOrdering-2");
producer.send(tmNormal2, DeliveryMode.PERSISTENT, 7, Message.DEFAULT_TIME_TO_LIVE);
producer.enableOrderingGroup(null);
// sending out ordering messages with priorities ranging from 0 to 5;
for (int i = 0; i < 10; i++)
{
TextMessage tm = producerSess.createTextMessage("Ordering" + i);
producer.send(tm, DeliveryMode.PERSISTENT, i % 6, Message.DEFAULT_TIME_TO_LIVE);
}
producer.disableOrderingGroup();
TextMessage tmNormal3 = producerSess.createTextMessage("NoOrdering-3");
producer.send(tmNormal3, DeliveryMode.PERSISTENT, 8, Message.DEFAULT_TIME_TO_LIVE);
TextMessage tmNormal4 = producerSess.createTextMessage("NoOrdering-4");
producer.send(tmNormal4, DeliveryMode.PERSISTENT, 9, Message.DEFAULT_TIME_TO_LIVE);
Session consumerSess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageConsumer consumer = consumerSess.createConsumer(queue1);
TextMessage rmNormal = (TextMessage)consumer.receive(1000);