JBoss Messaging Ordering Group Example

$Revision: 2750 $

Overview


This example creates a JMS Connection to a JBoss Messaging instance and uses it to create a session and two message producers, one normal producer called 'producer1', the other producer called 'producer' is used to produce ordering group messages. Then both producers send 5 messages (producer1 sending 2 and producer 3) to "queue/testQueue". The example then starts two consumer threads to receive these messages. Once the messages are all received, it check the results.

This example illustrates that ordering group messages will be delivered exactly in the same order as they are sent, even if the messages has different priorities and are consumed by multiple consumers at the same time.
This example relies on having access to a running JBoss Messaging instance. The JBoss Messaging instance must be installed and started according to the "Installation" paragraph from the release documentation. However, the example will automatically deploy its own queue, unless a queue with the same name is already deployed.

This example also relies on having access to jboss-messaging-client.jar archive that comes with the release bundle. If you run this example from an unzipped installation bundle, the example run script is correctly configured to find the client jar. Otherwise, you must modify example's build.xml accordingly.

Running the example

1. Set up the JBOSS_HOME environment variable to point to the JBoss instance you deployed JBoss Messaging into. For example, if you deployed JBoss Messaging in C:\jboss-4.2.0.GA\server\messaging\deploy, then your JBOSS_HOME value should be C:\jboss-4.2.0.GA

2. Go to the example's home directory

cd ...\examples\ordering-group

3. Run the example:

ant


The output of a successful run should be similar to:

Buildfile: build.xml

identify:
     [echo] ###########################################################################
     [echo] #                  Running the OrderingGroup example                      #
     [echo] ###########################################################################
     [echo] The queue:      testQueue
     [echo] The client jar: ../..//jboss-messaging-client.jar

sanity-check:

init:
    [mkdir] Created dir: /home/howard/apps/jboss-messaging-1.4.0.SP3-CP08/examples/ordering-group/output/classes

compile:
    [javac] Compiling 2 source files to /home/howard/apps/jboss-messaging-1.4.0.SP3-CP08/examples/ordering-group/output/classes

run:
     [java] Queue /queue/testQueue exists
     [java] Sending mormal message with lower priority 1
     [java] Sending message with priority 0
     [java] Sending message2 with priority 8
     [java] Sending normal message with priority 7
     [java] Sending message3 with priority 5
     [java] The message was successfully sent to the testQueue queue
     [java] len: 5
     [java] The example connected to JBoss Messaging version 1.4.0.SP3-CP08 (1.4)
     [java] 
     [java] #####################
     [java] ###    SUCCESS!   ###
     [java] #####################

BUILD SUCCESSFUL
Total time: 4 seconds




Troublesooting

1. I get "javax.jms.JMSSecurityException: User null is NOT authenticated"

You probably didn't install JBoss Messaging correctly. A fresh JBoss Messaging installation requires changes in the security configuration of a default JBoss instance, specifically a properly configured "messaging" security domain.  Follow the instructions from the "Installation" paragraph of the release documentation.