[jboss-cvs] JBoss Messaging SVN: r6769 - in trunk: examples/jms/message-group and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed May 13 10:44:41 EDT 2009
Author: jmesnil
Date: 2009-05-13 10:44:41 -0400 (Wed, 13 May 2009)
New Revision: 6769
Modified:
trunk/docs/user-manual/en/modules/message-grouping.xml
trunk/examples/jms/message-group/readme.html
trunk/examples/jms/message-group/src/org/jboss/jms/example/MessageGroupExample.java
Log:
user manual
* message grouping chapter
* updated message-group example
Modified: trunk/docs/user-manual/en/modules/message-grouping.xml
===================================================================
--- trunk/docs/user-manual/en/modules/message-grouping.xml 2009-05-13 14:43:50 UTC (rev 6768)
+++ trunk/docs/user-manual/en/modules/message-grouping.xml 2009-05-13 14:44:41 UTC (rev 6769)
@@ -1,8 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter id="message-grouping">
<title>Message Grouping</title>
- <para>blah.</para>
+ <para>Message groups are sets of messages that has the following characteristics:</para>
+ <itemizedlist>
+ <listitem><para>Messages in a message group share the same group id, i.e. they have same
+ group identifier property (<literal>JMSXGroupID</literal> for JMS,
+ <literal>_JBM_GROUP_ID</literal> for JBoss Messaging Core API).</para></listitem>
+ <listitem><para>Messages in a message group will be all delivered to no more
+ than one of the queue's consumers. The consumer that receives the first message of a group
+ will receive all the messages that belong to this group.</para></listitem>
+ </itemizedlist>
+
+ <section>
+ <title>Configuring Message Grouping</title>
+ <para>Message grouping must be enabled in the address-setting configuration
+ by using a specific <literal>distribution-policy-class</literal>:</para>
+ <programlisting>
+ <address-setting match="jms.queue.exampleQueue">
+ <distribution-policy-class>org.jboss.messaging.core.server.impl.GroupingRoundRobinDistributor</distribution-policy-class>
+ </address-setting>
+ </programlisting>
+ <para>By default, <literal>distribution-policy-class</literal> is set to <literal>org.jboss.messaging.core.server.impl.RoundRobinDistributor</literal>
+ and message groups will not be handled by the queue.</para>
+ </section>
+
+ <section>
+ <title>Using JMSX Group properties</title>
+ <para>Using JMS, the property name used to identify the message group is <literal>JMSXGroupID</literal>.</para>
+ <para>Within the same group, messages can also set a <literal>JMSXGroupSeq</literal>
+ <literal>int</literal> property (starting at 1).</para>
+ <programlisting>
+ // send 2 messages in the same group to ensure the same
+ // consumer will receive both
+ Message message = ...
+ message.setStringProperty("JMSXGroupID", "Group-0");
+ message.setIntProperty("JMSXGroupSeq", 1);
+ producer.send(message);
+
+ message = ...
+ message.setStringProperty("JMSXGroupID", "Group-0");
+ message.setIntProperty("JMSXGroupSeq", 2);
+ producer.send(message);
+ </programlisting>
+ </section>
-
-
+ <section>
+ <title>Using JBoss Messaging Core Group properties</title>
+ <para>Using JBoss Messaging Core API, the property name used to identify the message group is <literal>"_JBM_GROUP_ID""</literal>
+ (or the constant <literal>MessageImpl.HDR_GROUP_ID</literal>).</para>
+ </section>
+
+ <section>
+ <title>Example</title>
+ <para>The <ulink url="../../../../examples/jms/message-group/readme.html">Message Group example</ulink> shows
+ how message groups are configured and used with JMS.</para>
+ </section>
</chapter>
Modified: trunk/examples/jms/message-group/readme.html
===================================================================
--- trunk/examples/jms/message-group/readme.html 2009-05-13 14:43:50 UTC (rev 6768)
+++ trunk/examples/jms/message-group/readme.html 2009-05-13 14:44:41 UTC (rev 6769)
@@ -84,6 +84,7 @@
{
groupMessages[i] = session.createTextMessage("Group-0 message " + i);
groupMessages[i].setStringProperty(JBossMessage.JMSXGROUPID, "Group-0");
+ groupMessages[i].setIntProperty("JMSXGroupSeq", i + 1);
producer.send(groupMessages[i]);
System.out.println("Sent message: " + groupMessages[i].getText());
}
@@ -126,9 +127,13 @@
}
}</code>
</pre>
-
-
-
</ol>
+
+ <h2>More information</h2>
+
+ <ul>
+ <li>User Manual's <a href="../../../docs/user-manual/en/html_single/index.html#message-grouping">Message Grouping chapter</a></li>
+ </ul>
+
</body>
</html>
\ No newline at end of file
Modified: trunk/examples/jms/message-group/src/org/jboss/jms/example/MessageGroupExample.java
===================================================================
--- trunk/examples/jms/message-group/src/org/jboss/jms/example/MessageGroupExample.java 2009-05-13 14:43:50 UTC (rev 6768)
+++ trunk/examples/jms/message-group/src/org/jboss/jms/example/MessageGroupExample.java 2009-05-13 14:44:41 UTC (rev 6769)
@@ -90,6 +90,7 @@
{
groupMessages[i] = session.createTextMessage("Group-0 message " + i);
groupMessages[i].setStringProperty(JBossMessage.JMSXGROUPID, "Group-0");
+ groupMessages[i].setIntProperty("JMSXGroupSeq", i + 1);
producer.send(groupMessages[i]);
System.out.println("Sent message: " + groupMessages[i].getText());
}
@@ -143,7 +144,10 @@
try
{
TextMessage msg = (TextMessage)message;
- System.out.println("Message: [" + msg.getText() + "] received by " + name);
+ System.out.format("Message: [%s] received by %s, (%s in the group)\n",
+ msg.getText(),
+ name,
+ msg.getIntProperty("JMSXGroupSeq"));
messageReceiverMap.put(msg.getText(), name);
}
catch (JMSException e)
More information about the jboss-cvs-commits
mailing list