0 Replies Latest reply on Apr 16, 2009 3:58 AM by Yong Hao Gao

    message group example -- not working

    Yong Hao Gao Master

      Hi, I wrote a simple message grouping example to illustrate the effect of 'JMSXGroupID', but it doesn't always work as expected. All I do is create two consumers and send out 10 messages with JMSXGroupID set, and inspect that all the messages will went to only one of the consumers. But the result is random: sometimes all messages went to consumer1, sometimes consumer2 and sometimes both. I don't know what's wrong?

      The code :

       MessageConsumer consumer1 = session.createConsumer(queue);
       consumer1.setMessageListener(new SimpleMessageListener("consumer-1"));
       MessageConsumer consumer2 = session.createConsumer(queue);
       consumer2.setMessageListener(new SimpleMessageListener("consumer-2"));
       //Step 8. Create and send 10 text messages with group id 'Group-0'
       int msgCount = 10;
       TextMessage[] groupMessages = new TextMessage[msgCount];
       for (int i = 0; i < msgCount; i++)
       groupMessages = session.createTextMessage("Group-0 message " + i);
       groupMessages.setStringProperty(JBossMessage.JMSXGROUPID, "Group-0");
       System.out.println("Sent message: " + groupMessages.getText());

      And I added the config

       <address-settings match="jms.queue.exampleQueue">