290 total views, 1 views today

Test WebLogic JMS using Java

This section we walk through on testing the JMS Queue created in WebLogic Server using Java Messaging services. WebLogic Queue is a point to point messaging model that is it only has one producer and one consumer. We have created here two Java classes, WebLogicJMSProducer.java which send a text message to JMS Queue and WebLogicJMSConsumer.java which listens to the queen and if it finds a message then it consumes that message and prints it on a console. Let’s begin the WebLogic JMS Java example…


A JMS queue and connection factory setup is required in the WebLogic server. If you looking for instruction, click WebLogic JMS Setup

Add wljmsclient.jar in the class path. The jar file is present in <WEBLOGIC_HOME>\server\lib directory


In my local WebLogic,  I have the following JNDI names of the WebLogic Queue and Connection Factory

Queue: jdbc/JMSQueue

ConnectionFactory: jdbc/JMSConnectionFactory


The following java class connects to the WebLogic queue using connection factory and sends a text message “Good Morning”. Make sure to change the JNDI names according to your environment. Run this class in your IDE like eclipse


Once it ran, the A message will store in the JMS queue. To see the message

1. Login into WebLogic Console >> Expand Services >> Messaging >> JMS Modules >> Click on the module link >> Click on the Queue >>
Select the Monitoring tab. As you see below in the example, a message got produced in the Messaging Current. The consumer current is empty because we are not started yet the consumer

2. To see the message, click on the check box and click on the button Show Messages

100216_1956_TestWebLogi1 Test WebLogic JMS using Java


3. Click on the click, that is the message

100216_1956_TestWebLogi2 Test WebLogic JMS using Java


4. You will see the text we just sent from the java class below

100216_1956_TestWebLogi3 Test WebLogic JMS using Java

Let’s create a consumer


This class is a consumer which listens for the WebLogic queue for the incoming message. If it finds any new message then it reads it and prints it on the console. It uses the connectionFactory to create the connection to JMS Server and uses the QUEUE to listens for a new message .


I ran it from eclipse. The text message we sent it from the producer got consumed and prints it on the console

100216_1956_TestWebLogi4 Test WebLogic JMS using Java

If you refresh the same WebLogic Queue monitoring page again , you will notice that the Consumers Current will be 1 as like below

100216_1956_TestWebLogi5 Test WebLogic JMS using Java

Let’s re-run the WebLogicProducer.java with a different String ‘How are you’. The consumer prints the second message on the console

100216_1956_TestWebLogi6 Test WebLogic JMS using Java

govindan Test WebLogic JMS using Java
Connect me


Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
govindan Test WebLogic JMS using Java
Connect me
Like us on Facebook.