# JBoss Messaging Distributed Queue Example

$Revision: 82920 $

## Overview

This example demonstrates how to write JMS code that connects to a JBoss Messaging cluster and sends messages to a distributed queue. The example creates two connections to two distinct cluster nodes on which we have previously deployed a distributed queue. The example sends and receives messages using both connections.
This example relies on having access to a running JBoss Messaging cluster with at least two nodes. The JBoss Messaging cluster must be installed and started according to the user guide.
For JBoss5, you should copy all as messaging-node0, configure mysql as a database, make it clustered, and copy it as messaging-node1. Start each instance as:
./run.sh -c messaging-node0 -Djboss.service.binding.set=ports-01
and in another window
./run.sh -c messaging-node1 -Djboss.service.binding.set=ports-02 -Djboss.messaging.ServerPeerID=1

## Running the example

1. Make sure that a JBoss Messaging cluster with at least two nodes is up and running.
2. Go to the example's home directory
cd ...\examples\distributed-queue
3. Run the example:
ant
The output of a successful run should be similar to:

$ ant Buildfile: build.xml identify: [echo] ########################################################################### [echo] # Running the DISTRIBUTED QUEUE example # [echo] ########################################################################### [echo] The topic: testDistributedQueue [echo] The client jar: ../../../output/lib/jboss-messaging-client.jar sanity-check: init: [mkdir] Created dir: C:\work\src\svn\messaging\docs\examples\distributed-queue\output [mkdir] Created dir: C:\work\src\svn\messaging\docs\examples\common\output compile: [javac] Compiling 2 source files to C:\work\src\svn\messaging\docs\examples\common\output [javac] Compiling 2 source files to C:\work\src\svn\messaging\docs\examples\distributed-queue\output run: [java] Distributed queue /queue/testDistributedQueue exists [java] The message was successfully sent to the distributed queue [java] MessageListener0 received message: Hello! [java] MessageListener1 received message: Another Hello! [java] The example connected to JBoss Messaging version 1.4.1.GA (1.4) [java] ##################### [java] ### SUCCESS! ### [java] ##################### BUILD SUCCESSFUL Total time: 4 seconds