Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 1fv3

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue

Recently, for a client of ours, we had to check if a JMS Queue on an 14c Oracle WebLogic Server was correctly configured and working.

In this article, you can read more about the steps I took to send messages to and receive messages from an Oracle WebLogic Server JMS Queue, by using the Java programs QueueSend.java and QueueReceive.java.

On my laptop, I already had a VirtualBox appliance with an Oracle OSB 12c training environment, which included Oracle JDeveloper 12c (12.2.1.1.0) with an integrated WebLogic Server.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 2

In the past, this training environment was used for an Oracle OSB and SOA Suite training, I gave to my junior colleagues.

In order to have a quick start, I had a look on the internet and found the following articles (by John-Brown Evans) on the Oracle Blogs:

  • JMS Step 1 – How to Create a Simple JMS Queue in Weblogic Server 11g

[https://blogs.oracle.com/fusionmiddlewaresupport/post/jms-step-1-how-to-create-a-simple-jms-queue-in-weblogic-server-11g]

  • JMS Step 2 – Using the QueueSend.java Sample Program to Send a Message to a JMS Queue

[https://blogs.oracle.com/fusionmiddlewaresupport/post/jms-step-2-using-the-queuesendjava-sample-program-to-send-a-message-to-a-jms-queue]

  • JMS Step 3 – Using the QueueReceive.java Sample Program to Read a Message from a JMS Queue

[https://blogs.oracle.com/fusionmiddlewaresupport/post/jms-step-3-using-the-queuereceivejava-sample-program-to-read-a-message-from-a-jms-queue]

Although, in the articles WebLogic Server 11g was used, they also worked in my 12c training environment and also in the 14c environment of our client.

I simply followed the instructions and was able to get it working.

My integrated WebLogic Server

In order to get started with the steps in the Oracle Blogs, from within JDeveloper, I started the integrated WebLogic Server.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 3

With the following output:

*** Using HTTP port 7101 ***
*** Using SSL port 7102 ***
/home/oracle/training/system12.2.1.1.42.160607.2047/DefaultDomain/bin/startWebLogic.sh
[Starting IntegratedWebLogicServer.]
[waiting for the server to complete its initialization...]
*****************************************************
…
IntegratedWebLogicServer startup time: 478817 ms.
[IntegratedWebLogicServer started.]

Next, I opened the WebLogic Server Administration Console 12c in a web browser via url:

http://localhost:7101/console

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 4

In the Domain Structure, I clicked on Environment | Servers.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 5

Next, in order to show the settings of this AdminServer, I clicked on the “DefaultServer” link:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 6

So, as you can see, my AdminServer listens on port 7101.

Step 1, creating the necessary JMS resources in WebLogic

Step 1 of the Oracle Blog shows the steps to create the following JMS resources (a JMS queue and its dependent objects) in WebLogic:

Reource Name Type JNDI Name
TestJMSServer JMS Server
TestJMSModule JMS Module
TestSubdeployment Subdeployment
TestConnectionFactory Connection Factory jms/TestConnectionFactory
TestJMSQueue JMS Queue jms/TestJMSQueue

[https://blogs.oracle.com/fusionmiddlewaresupport/post/jms-step-1-how-to-create-a-simple-jms-queue-in-weblogic-server-11g]

I simply followed the instructions.

In the WebLogic Server Administration Console 12c, I navigated to Home | Messaging.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 7

Below is a list of the JMS resources that were created:

  • JMS Servers (via Home | Messaging | JMS Servers):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 8

JMS Server, TestJMSServer:

Below you see the details of the JMS Server that was created, including a File Store named TestFileStore.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 9

Below, you see the first step in creating the JMS Server:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 10

To create a File Store, that I used for the JMS Server, as Persistent Store, I had to take some steps, you can see below:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 11

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 12

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 13

As you can see, in the step shown above, first I had to create the directory on the file system.

The pathname to the directory on the file system where the file store is kept. This directory must exist on your system, so be sure to create it before completing this tab.

In order to create the File Store directory, I used the following command on the Linux Command Prompt:

[oracle@integration /]$ mkdir /u02

With the following output:

mkdir: cannot create directory `/u02’: Permission denied

In order to create the File Store directory, I had to change to user root. I used the following commands on the Linux Command Prompt:

[oracle@integration /]$ su
Password: 
[root@integration /]# mkdir /u02
[root@integration /]# ls -latr

With the following output:

drwxr-xr-x.   2 root   root      4096 Sep 17 10:54 u02

In order to change the owner of the File Store directory, to oracle, I used the following commands on the Linux Command Prompt:

[root@integration /]# chown -R oracle: u02
[root@integration /]# ls -latr

With the following output:

drwxr-xr-x.   2 oracle oinstall  4096 Sep 17 10:54 u02

In order to log out of the root account, I used the following command on the Linux Command Prompt

[root@integration /]# exit
exit

With the following output:

[oracle@integration /]$

In order to create the File Store directory, I used the following commands on the Linux Command Prompt

[oracle@integration /]$ cd /u02
[oracle@integration u02]$ mkdir filestores
[oracle@integration u02]$ cd filestores/
[oracle@integration filestores]$ mkdir TestFileStore
[oracle@integration filestores]$ ls -latr

With the following output:

total 12
drwxr-xr-x. 3 oracle oinstall 4096 Sep 17 10:54 ..
drwxr-xr-x. 3 oracle oinstall 4096 Sep 17 11:17 .
drwxr-xr-x. 2 oracle oinstall 4096 Sep 21 09:38 TestFileStore

In the WebLogic Server Administration Console 12c, I continued with creating the JMS Server:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 14

As you can see, as File Store directory I used:

/u02/filestores/TestFileStore

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 15

In order to check the File Store creation, I used the following command on the Linux Command Prompt

[oracle@integration filestores]$ cd TestFileStore/
[oracle@integration TestFileStore]$ ls -latr

With the following output:

total 1036
drwxr-xr-x. 3 oracle oinstall    4096 Sep 17 11:17 ..
drwxr-xr-x. 2 oracle oinstall    4096 Sep 21 09:38 .
-rw-r-----. 1 oracle oinstall 1049088 Sep 21 09:39 TESTFILESTORE000000.DAT
  • JMS Modules (via Home | Messaging | JMS Modules):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 16

JMS Module, TestJMSModule with resources and Subdeployment:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 17

  • Subdeployment, TestSubdeployment:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 18

  • JMS resource, Connection Factory, TestConnectionFactory:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 19

  • JMS resource, Queue, TestJMSQueue:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 20

So, at the end of Step 1 of the Oracle Blog , I had the necessary resources available , including:

In order to view the JNDI Tree, in the Domain Structure, I navigated to Environment | Servers | DefaultServer (admin):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 21

I clicked on the “View JNDI Tree” link:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 22

In the JNDI Tree Structure, I clicked on the “TestConnectionFactory” link:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 23

In the JNDI Tree Structure, I clicked on the “TestJMSQueue” link:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 24

I also navigated to the TestJMSQueue’s Monitoring page (via Home | Messaging | JMS Modules | TestJMSModule | TestJMSQueue):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 25

JMS Step 2 – Using the QueueSend.java Sample Program to Send a Message to a JMS Queue

Step 2 of the Oracle Blog shows how to use a sample Java program (QueueSend.java) to write a message to a JMS queue. This Java program is based on a sample program provided with the WebLogic Server installation.

Below, you can see the content of file QueueSend.java:
[in bold, I highlighted the changes I made, with regard to the code in the Oracle Blog]

package examples.jms.queue;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Hashtable;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/** This example shows how to establish a connection
* and send messages to the JMS queue. The classes in this
* package operate on the same JMS queue. Run the classes together to
* witness messages being sent and received, and to browse the queue
* for messages. The class is used to send messages to the queue.
*
* @author Copyright © 1999-2005 by BEA Systems, Inc. All Rights Reserved.
*/
public class QueueSend
{
 // Defines the JNDI context factory.
 Public final static String JNDI_FACTORY=”weblogic.jndi.WLInitialContextFactory”;

 // Defines the JMS context factory.
 Public final static String JMS_FACTORY=”jms/TestConnectionFactory”;

 // Defines the queue.
 Public final static String QUEUE=”jms/TestJMSQueue”;
 private QueueConnectionFactory qconFactory;
 private QueueConnection qcon;
 private QueueSession qsession;
 private QueueSender qsender;
 private Queue queue;
 private TextMessage msg;

 /**
  * Creates all the necessary objects for sending
  * messages to a JMS queue.
  *
  * @param ctx JNDI initial context
  * @param queueName name of queue
  * @exception NamingException if operation cannot be performed
  * @exception JMSException if JMS fails to initialize due to internal error
  */
 public void init(Context ctx, String queueName)
    throws NamingException, JMSException
 {
    qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
    qcon = qconFactory.createQueueConnection();
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queue = (Queue) ctx.lookup(queueName);
    qsender = qsession.createSender(queue);
    msg = qsession.createTextMessage();
    qcon.start();
 }

 /**
  * Sends a message to a JMS queue.
  *
  * @param message  message to be sent
  * @exception JMSException if JMS fails to send message due to internal error
  */
 public void send(String message) throws JMSException {
    msg.setText(message);
    qsender.send(msg);
 }

 /**
  * Closes JMS objects.
  * @exception JMSException if JMS fails to close objects due to internal error
  */
 public void close() throws JMSException {
    qsender.close();
    qsession.close();
    qcon.close();
 }
/** main() method.
 *
 * @param args WebLogic Server URL
 * @exception Exception if operation fails
 */
 public static void main(String[] args) throws Exception {
    if (args.length != 1) {
     System.out.println(“Usage: java examples.jms.queue.QueueSend WebLogicURL”);
     return;
    }
    ooleanontexti c = getInitialContext(args[0]);
    QueueSend qs = new QueueSend();
    qs.init(ic, QUEUE);
    readAndSend(qs);
    qs.close();
 }

 private static void readAndSend(QueueSend qs)
    throws IOException, JMSException
 {
    BufferedReader msgStream = new BufferedReader(new InputStreamReader(System.in));
    String line=null;
    oolean quitNow = false;
    do {
     System.out.print(“Enter message (\”quit\” to quit): \n”);
     line = msgStream.readLine();
     if (line != null && line.trim().length() != 0) {
       qs.send(line);
       System.out.println(“JMS Message Sent: “+line+”\n”);
       quitNow = line.equalsIgnoreCase(“quit”);
     }
    } while (! quitNow);

 }

 private static InitialContext getInitialContext(String url)
    throws NamingException
 {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
    env.put(Context.PROVIDER_URL, url);
    return new InitialContext(env);
 }
}

As is mentioned in the Oracle Blog, this class can be used from JDeveloper and from the file system (for example Linux).

I tried both ways. You can read more about that later on in this article.

JMS Step 3 – Using the QueueReceive.java Sample Program to Read a Message from a JMS Queue

Step 3 of the Oracle Blog shows how to use a sample Java program (QueueReceive.java) to read the message from a JMS queue. This Java program is based on a sample program provided with the WebLogic Server installation.

Below, you can see the content of file QueueSend.java:
[in bold, I highlighted the changes I made, with regard to the code in the Oracle Blog]

package examples.jms.queue;
import java.util.Hashtable;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* This example shows how to establish a connection to
* and receive messages from a JMS queue. The classes in this
* package operate on the same JMS queue. Run the classes together to
* witness messages being sent and received, and to browse the queue
* for messages.  This class is used to receive and remove messages
* from the queue.
*
* @author Copyright (c) 1999-2005 by BEA Systems, Inc. All Rights Reserved.
*/
public class QueueReceive implements MessageListener
{
 // Defines the JNDI context factory.
 public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";
 // Defines the JMS connection factory for the queue.
 public final static String JMS_FACTORY="jms/TestConnectionFactory";
 // Defines the queue.
 public final static String QUEUE="jms/TestJMSQueue";
 private QueueConnectionFactory qconFactory;
 private QueueConnection qcon;
 private QueueSession qsession;
 private QueueReceiver qreceiver;
 private Queue queue;
 private boolean quit = false;
/**
 * Message listener interface.
 * @param msg  message
 */
 public void onMessage(Message msg)
 {
    try {
     String msgText;
     if (msg instanceof TextMessage) {
       msgText = ((TextMessage)msg).getText();
     } else {
       msgText = msg.toString();
     }
     System.out.println("Message Received: "+ msgText );
     if (msgText.equalsIgnoreCase("quit")) {
       synchronized(this) {
         quit = true;
         this.notifyAll(); // Notify main thread to quit
       }
     }
    } catch (JMSException jmse) {
     System.err.println("An exception occurred: "+jmse.getMessage());
    }
 }
 /**
  * Creates all the necessary objects for receiving
  * messages from a JMS queue.
  *
  * @param   ctx    JNDI initial context
  * @param    queueName    name of queue
  * @exception NamingException if operation cannot be performed
  * @exception JMSException if JMS fails to initialize due to internal error
  */
 public void init(Context ctx, String queueName)
    throws NamingException, JMSException
 {
    qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
    qcon = qconFactory.createQueueConnection();
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queue = (Queue) ctx.lookup(queueName);
    qreceiver = qsession.createReceiver(queue);
    qreceiver.setMessageListener(this);
    qcon.start();
 }
 /**
  * Closes JMS objects.
  * @exception JMSException if JMS fails to close objects due to internal error
  */
 public void close()throws JMSException
 {
    qreceiver.close();
    qsession.close();
    qcon.close();
 }
/**
 * main() method.
 *
 * @param args  WebLogic Server URL
 * @exception  Exception if execution fails
 */
 public static void main(String[] args) throws Exception {
    if (args.length != 1) {
     System.out.println("Usage: java examples.jms.queue.QueueReceive WebLogicURL");
     return;
    }
    InitialContext ic = getInitialContext(args[0]);
    QueueReceive qr = new QueueReceive();
    qr.init(ic, QUEUE);
    System.out.println(
        "JMS Ready To Receive Messages (To quit, send a \"quit\" message).");
    // Wait until a "quit" message has been received.
    synchronized(qr) {
     while (! qr.quit) {
       try {
         qr.wait();
       } catch (InterruptedException ie) {}
     }
    }
    qr.close();
 }
 private static InitialContext getInitialContext(String url)
    throws NamingException
 {
    Hashtable<string,string> env = new Hashtable<string,string>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
    env.put(Context.PROVIDER_URL, url);
    return new InitialContext(env);
 }
}</string,string></string,string>

As is mentioned in the Oracle Blog, this class can be used from JDeveloper and from the file system (for example Linux).

I tried both ways, as you can read in the following sections.

Using the classes QueueSend and QueueReceive from JDeveloper

Next, I followed the instructions from Step 2 and Step 3 of the Oracle Blog.

In JDeveloper, I created an application and a project.

Via a shared folder in my training environment, I copied the files QueueSend.java and QueueReceive.java (including the correct JNDI names) to the src directory.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 26

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 27

Next, I added the following library to the JDeveloper project.

Right-click the QueueSend project in the navigation menu and select Libraries and Classpath , then Add JAR/Directory

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 28

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 29

Remark:
From the running IntegratedWebLogicServer – Log, in the CLASSPATH setting, I could see the directory with the weblogic.jar:

/u01/app/oracle/fmw/12.2/wlserver/server/lib/weblogic.jar

In order to automatically pass the required parameter (pointing to the WLS installation containing the JMS queue), I edited the project’s Run/Debug/Profile.

Select the project properties, select Run/Debug/Profile and edit the Default run configuration.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 30

In the “Launch Settings”, I used the following “Program Arguments”:

t3://localhost:7101

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 31

Remark:
As you may remember, my AdminServer listens on port 7101.

Then, in the “Tools Settings”, I checked “Allow Program Input”.

You need to make one more change to the project. If you execute it now, it will prompt for the payload for the JMS message, but you won’t be able to enter it by default in JDeveloper. You need to enable program input for the project first.

Select the project’s properties, then Tool Settings, then check the Allow Program Input checkbox at the bottom and Save.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 32

Executing classes QueueSend and QueueReceive from JDeveloper

Next, I executed (via right-click | Run) file QueueSend.java and entered the following payload text in the text entry field:

  • my payload1
  • my payload2
  • quit

Now when you execute the project, you will get a text entry field at the bottom into which you can enter the payload. You can enter multiple messages until you enter “quit”, which will cause the program to stop.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 33

With the following output:

Enter message ("quit" to quit): 
my payload1
JMS Message Sent: my payload1

Enter message ("quit" to quit): 
my payload2
JMS Message Sent: my payload2

Enter message ("quit" to quit): 
quit
JMS Message Sent: quit

Process exited with exit code 0.

In the WLS console, go to the queue and select Monitoring to confirm that a new message was written to the queue.

So, again I navigated to the TestJMSQueue’s Monitoring page (via Home | Messaging | JMS Modules | TestJMSModule | TestJMSQueue):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 34

Above, you can see that there are 3 current messages.

Next, I checked “TestJMSModule!TestJMSQueue” and clicked the “Show Messages” button.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 35

Then, I clicked on link “ID:<320366.1758465002553.0>”:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 36

Executing class QueueReceive from JDeveloper

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 37

Next, I executed (via right-click | Run) file QueueReceive.java.

With the following output:

JMS Ready To Receive Messages (To quit, send a "quit" message).
Message Received: my payload1
Message Received: my payload2
Message Received: quit
Process exited with exit code 0.

So, again I navigated to the TestJMSQueue’s Monitoring page (via Home | Messaging | JMS Modules | TestJMSModule | TestJMSQueue):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 38

Above, you can see that there are 0 current messages. So all the 3 previous messages were received.

Using class QueueSend from the file system

Next, I followed the instructions from Step 2 of the Oracle Blog.

First I created the directory:

/home/oracle/examples/jms/queue

I used the following commands on the Linux Command Prompt:

cd $HOME
mkdir examples
cd examples/
mkdir jms
cd jms
mkdir queue
cd queue

Next, via a shared folder in my training environment, I copied the file QueueSend.java (including the correct JNDI names) to this directory.

In order to compile the Java file, I used the following commands on the Linux Command Prompt:

cd /home/oracle/examples/jms/queue

/u01/app/oracle/java/jdk1.8.0_91/bin/javac QueueSend.java

In order to list the files, I used the following command on the Linux Command Prompt:

ls -latr

With the following output:

total 24
drwxr-xr-x. 3 oracle oinstall 4096 Sep 17 12:39 ..
-rwxrwx---. 1 oracle oinstall 3801 Sep 17 12:42 QueueSend.java
-rw-r--r--. 1 oracle oinstall 3562 Sep 17 14:14 QueueSend.class
drwxr-xr-x. 2 oracle oinstall 4096 Sep 17 15:36 .

In order to execute the Java program from the source’s top-level directory, I used the following commands on the Linux Command Prompt:

cd /home/oracle 

/u01/app/oracle/java/jdk1.8.0_91/bin/java -classpath /home/oracle:/u01/app/oracle/fmw/12.2/wlserver/server/lib/weblogic.jar examples.jms.queue.QueueSend t3://localhost:7101

This will prompt for a text input. You can type “quit” to end the program.

Enter message (“quit” to quit):
my payload3
JMS Message Sent: my payload3

Enter message (“quit” to quit):
my payload4
JMS Message Sent: my payload4

Enter message (“quit” to quit):
quit
JMS Message Sent: quit

Remark:
If you receive an error like the following:

Error: Could not find or load main class examples.jms.queue.QueueSend

You probably have to first go to the correct source’s top-level directory and then execute the command. 

Also, have a look at:
Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 39
AI responses may include mistakes. Learn more

So, again I navigated to the TestJMSQueue’s Monitoring page (via Home | Messaging | JMS Modules | TestJMSModule | TestJMSQueue):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 40

Above, you can see that there are 3 current messages.

Next, I checked “TestJMSModule!TestJMSQueue” and clicked the “Show Messages” button.

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 41

Then, I clicked on link “ID:<320366.1758465667565.0>”:

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 42

Using class QueueReceive from the file system

Next, I followed the instructions from Step 3 of the Oracle Blog.

Via a shared folder in my training environment, I copied the file QueueReceive.java (including the correct JNDI names) to directory /home/oracle/examples/jms/queue.

In order to compile the Java file, I used the following commands on the Linux Command Prompt:

cd /home/oracle/examples/jms/queue

/u01/app/oracle/java/jdk1.8.0_91/bin/javac QueueReceive.java

In order to list the files, I used the following command on the Linux Command Prompt:

ls -latr

With the following output:

total 24
drwxr-xr-x. 3 oracle oinstall 4096 Sep 17 12:39 ..
-rwxrwx---. 1 oracle oinstall 3801 Sep 17 12:42 QueueSend.java
-rw-r--r--. 1 oracle oinstall 3562 Sep 17 14:14 QueueSend.class
-rwxrwx---. 1 oracle oinstall 3874 Sep 17 15:35 QueueReceive.java
-rw-r--r--. 1 oracle oinstall 3573 Sep 17 15:35 QueueReceive.class
drwxr-xr-x. 2 oracle oinstall 4096 Sep 17 15:36 .

In order to execute the Java program from the source’s top-level directory, I used the following commands on the Linux Command Prompt:

cd /home/oracle 

/u01/app/oracle/java/jdk1.8.0_91/bin/java -classpath /home/oracle:/u01/app/oracle/fmw/12.2/wlserver/server/lib/weblogic.jar examples.jms.queue.QueueReceive t3://localhost:7101

This will print a message that it is ready to receive messages or to send a “quit”message to end.
The program will read all messages in the queue and print them to the standard output until it receives a message with the payload “quit”.

With the following output:

JMS Ready To Receive Messages (To quit, send a "quit" message).
Message Received: my payload3
Message Received: my payload4
Message Received: quit

So, again I navigated to the TestJMSQueue’s Monitoring page (via Home | Messaging | JMS Modules | TestJMSModule | TestJMSQueue):

Using Java to send messages to and receive messages from an Oracle WebLogic Server JMS Queue lameriks 2025 09 43

Above, you can see that there are 0 current messages. So all the 3 previous messages were received.

After this I stopped the integrated WebLogic Server and closed JDeveloper.

By the way, also the following articles on the Oracle Blog can be found with regard to this topic:

I conclude my article.

In this article, you can read more about the steps I took to send messages to and receive messages from an Oracle WebLogic Server JMS Queue, by using the Java programs QueueSend.java and QueueReceive.java. As a base for this, I used some articles (by John-Brown Evans) on the Oracle Blogs.

In this way we could conveniently check, for a client of ours, that their JMS Queue on an 14c Oracle WebLogic Server was correctly configured and working.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.