# JBoss Messaging Queue Example

$Revision: 1.6 $

## Overview

This example creates a JMS Connection to a JBoss Messaging instance and uses it to create a session and a message producer, which sends a message to a queue. The first connection is closed, and a second connection is created and used to create a message consumer that reads a single message from the queue. The example is considered successful if the message consumer receives without any error the message that was sent by the producer.
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.0.3SP1\server\messaging\deploy, then your JBOSS_HOME value should be C:\jboss-4.0.3SP1
2. Go to the example's home directory
cd ...\examples\queue
3. Run the example:
ant
The output of a successful run should be similar to:

$ ant Buildfile: build.xml identify: [echo] XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [echo] X Running the QUEUE example X [echo] XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [echo] The queue: testQueue sanity-check: init: [mkdir] Created dir: C:\work\src\cvs\jboss-head\jms\docs\examples\queue\output [mkdir] Created dir: C:\work\src\cvs\jboss-head\jms\docs\examples\common\output compile: [javac] Compiling 2 source files to C:\work\src\cvs\jboss-head\jms\docs\examples\common\output [javac] Compiling 1 source file to C:\work\src\cvs\jboss-head\jms\docs\examples\queue\output run: [java] Queue /queue/testQueue exists [java] The message was successfully sent to the testQueue queue [java] Received message: Hello! [java] The example connected to JBoss Messaging version 1.0.1.CR3 (1.0) [java] ##################### [java] ### SUCCESS! ### [java] ##################### BUILD SUCCESSFUL Total time: 5 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.