JMS Client using JBoss 7 – Point-To-Point Messaging

This example will take you through step by step on practical implementation how you can configure a JMS Client using JBoss Application Server 7.1.1. I won’t discuss theoretical part here but if you need to know JMS related various keywords then you can go through the tutorial at http://www.roytuts.com/configure-jms-client-using-glassfish-3/

In point-to-point messaging system there are only one sender(sends message) and one receiver(receives message sent by sender). In this model we have to use queue for sender to send the message and later receiver will receive the message from that queue.

Prerequisites

JBoss Application Server 7.1.1
JDK 1.6
Eclipse
Jar – jboss-client.jar (located at <JBOSS_HOME>\bin\client)

We will see now step by step implementation of JMS client

Step 1. Run the JBoss application server using the below command from command prompt. Open command prompt, navigate to <JBOSS_HOME>\bin and execute the below command. The below command will run the application server. You can stop the server by pressing “Ctrl+C” and then type “Terminate batch job (Y/N)? y”

 

Once the server is up and running you will see snippets of output at the bottom similar to the below

 

Step 2. Now we need to create a user for authentication or running the application. So we will create a guest user. So open command prompt, navigate to <JBOSS_HOME>\bin and execute the below command.

 

Enter the below inputs as shown in the screen-shot. You can give any username and password as per your choice. I have given here usernameuser and passwordkolkata

JMS Client using JBoss 7

Step 3. Now create a java project in Eclipse or any Java based IDE. Configure Eclipse using jboss-client.jar (located at <JBOSS_HOME>\bin\client) which is required for JMS application.

Step 4. We will create Message Sender which will sends message to the queue.

 

Step 5. We will create a Message Receiver which will receive message from the queue.

 

Step 5. Now how did we get those ConnectionFactory and Destination(Queue) names in the above java codes. Navigate to the location <JBOSS_HOME>\standalone\configuration and open the xml file standalone-full.xml and look for tags <jms-connection-factories> and <jms-destinations>. You can also create and use your own ConnectionFactory or Destination. Also note that I have written “jms/RemoteConnectionFactory” instead of “RemoteConnectionFactory” and “jms/queue/test” instead of “queue/test” otherwise it won’t work.

Excert is given below from standalone-full.xml

 

Step 6. Now run MsgSender.java or MsgReceiver.java in any order and look at the console output. You won’t get any output at MsgSender.java console but you will see below output at MsgReceiver.java console

 

That’s all. Thanks for your reading.

Soumitra

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.