Example 2: Receive/Send MDB (full XA)


This example is a MDB which receives text messages from queue "testqueue2", prints it to System.out and forwards the message to "testqueue3". You will find the output in JBoss' server.log. Use the SwiftMQ Explorer to view the resulting messages in "testqueue3".

Note that this example uses delivery option "B" of the SwiftMQ JCA 1.6 resource adapter to get proper XA support from JBoss.

Download this example (ZIP).

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

You will find all necessary bindings/configuration in the "ejb-jar.xml" .

Deploy the EAR Archive

Copy "withsendmdb.ear" to "standalone/deployments" of your JBoss distribution.

Test the Example

To test the example you need to send some text messages to queue "testqueue2@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 testqueue2@router1 100

It sends 100 messages to "testqueue2@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 MDB instances.

Open the SwiftMQ Explorer and connect to the router. View "testqueue3" and you should see the 100 forwarded messages there.