[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - message group example -- not working
gaohoward
do-not-reply at jboss.com
Thu Apr 16 03:58:57 EDT 2009
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");
| producer.send(groupMessages);
| System.out.println("Sent message: " + groupMessages.getText());
| }
|
And I added the config
|
| <address-settings match="jms.queue.exampleQueue">
| <distribution-policy-class>org.jboss.messaging.core.server.impl.GroupingRoundRobinDistributor</distribution-policy-class>
| </address-settings>
|
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4225809#4225809
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4225809
More information about the jboss-dev-forums
mailing list