This example is a MDB which receives text messages from queue "testqueue", prints it to System.out and forwards the message to "testqueue2". You will find the output in WebSphere's SystemOut.log. Use the SwiftMQ Explorer to view the resulting messages in "testqueue2".
After download, unzip it and go to the "withsendmdb" 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 "withsendmdb/build" and call:
ant -Dlib=<was-lib-dir>
where <was-lib-dir> must point to the "lib" directory (where the j2ee.jar is stored) of WebSphere.
If you have the example 1 still deployed you must uninstall it from WebSphere before you can run this example because both examples are listening to the same queue!
Connect with the administration console and log in. On the left side expand the node "Applications" and click on "Install New Application":
In the panel on the right side choose "Local file system" and use the "Browse" button to locate the "withsendmdb.ear" file in the "withsendmdb" directory of this example.
Choose "Next" until you are in "Step 3" of the configuration panel. On the right side choose "Activation Specification" and specify the JNDI name "swiftmqinbound1". This links this MDB to the message endpoint "swiftmqinbound1" which you've defined during the Resource Adapter configuration. The actual configuration of this Activation Specification will be done by the properties out of the ejb-jar.xml. You might take a look there (config/ejbjar/META-INF in the example zip).
Next step is to map resource refs to resources. In the ejb-jar.xml of this MDB is a resource-ref which points to a connection factory "CF" and a queue "testqueue2". On the following panel you define the mapping to the actual resources. As you remember, the Resource Adapter configuration has a connection factory in JNDI under "jms/CF" and the queue "testqueue2" under "jms/testqueue2".
In the upper section of the panel select the JNDI name "jms/CF" of the connection factory and click "Apply". The authentication method should be "none" or "Use default mode". Click "Apply" here as well. At last select the single entry in the table at the bottom and specify "jms/CF" as the JNDI name:
Choose "Next" and "Continue" on the next panel. The next panel will map the resource reference to the queue "testqueue2" to the actual JNDI name "jms/testqueue2":
Choose "Next" and then "Finish". The EAR will be deployed. Click on "Save to Master Configuration" and "Save".
The application is now deployed but not yet started. On the left side expand the node "Applications" and click on "Enterprise Applications":
On the right panel you will now see the list of installed applications:
Select "WithSendMessageApp" and click on "Start" which starts the application:
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 WebSphere's SystemOut.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 up to 5 MDB instances.
Open the SwiftMQ Explorer and connect to the router (running inside WebSphere). View "testqueue2" and you should see the 100 forwarded messages there.