Example 1: Receive-only MDB

Introduction

This example is a simple MDB which receives text messages from queue "testqueue" and prints it to System.out. You will find the output in JBoss' server.log.

Download this example (ZIP).

After download, unzip it and go to the "simplemdb" directory where you will find the EAR archive.

If you want to change and rebuild the example, you need Apache ant on your machine. Switch to "simplemdb/build" and call:

    ant -Dlib=<jboss-lib-dir>

where <jboss-lib-dir> must point to the "server/default/lib" directory of JBoss.

You will find all necessary bindings/configuration in the "ejb-jar.xml" (standard J2EE deployment descriptor) and "jboss.xml" (JBoss specific deployment descriptor).

Deploy the EAR Archive

If JBoss is running, stop it. Then copy "simplemdb.ear" to "server/default/deploy" of your JBoss distribution. Start JBoss.

Test the Example

To test the example you need to send some text messages to queue "testqueue@router1". You can use the SwiftMQ example P2PSender to do that.

Switch to the router's distribution directory and there to "samples/router_network". From here run:

      starter P2PSender smqp://localhost:4001 plainsocket@router1 testqueue@router1 100

It sends 100 messages to "testqueue@router1". Now have a look in JBoss' server.log file. You should see the printouts of the MDB for each message. Note that the messages are not printed in order because the messages are processed asynchronously from multiple instances.