Java Messing
Service is one of the Important Service that every Application Server Provides.
There are 2 types of Messaging Models
Point-To-Point
– This enables the delivery of the message to exactly one Recipient.
Publisher-Subscribe
– This enables the delivery of the message to multiple recipients.
In this
article we will see how to configure PTP model with Queue. Messaging application
in PTP sned and receive messages using Queue. In this model a Queue-sender
sends a message and a Queue-receiver receives the messages .In this case the
Queue-sender sends a message to a Queue to which the Receiver listens.
Configure a JMS Server
Follow the
Steps to configure the JMS Server in Weblogic.
1. Move to
Weblogic Admin Console à Messaging à JMS Servers. Once you click here,
2. Target
the JMS Server to Weblogic Servers
Configure JMS System Module
The JMS
Module holds the Queue and Topics. To configure JMS System Module
1. Move to
Services à Messaging à JMS Module,
3.Click Next and in the next window , check "would like to add resources to the jsm module"
Create a Sub Deployment
To Create a
Sub Deployment, Click on the Sub deployment tab in the System Module.
1. Create a
Sub Deployment , Name=SystemModule
2. Target it
to the JMS Server
Create a Connection Factory
To create a
Connection Factory, Click on the New under the Configuration Tab of the JMS
System Module
1. Check the Connection Factory and Click Next
2. Create a
Connection Factory By Providing the JNDI name = CF1
2. Target
the Connection Factory to the Sub Deployment by Clicking on the Advanced
Targeting.
3. Select
the Sub Deployment and Check the ‘JMS Server’ in the Servers tab
Create a Queue
Click on the
New under the Configuration Tab of the JMS System Module
1. Select
Queue and Click Next
2. Provide
the Necessary Details - JNDI Name = Queue1
3. Target
the Queue to the Sub Deployment by Clicking on the Advanced Targeting.
4. Select
the Sub Deployment and Check the ‘JMS Server’ in the Servers tab
Now in the
JMS resource page ,we can see both Connection Factory and Queue are been
Configured.
Test the Setup
Download the
QueueSend.java and QueueReceive.java
Compile both
the class providing the location of the jms libraries like
javac
-classpath
.:/root/Oracle/Middleware/wlserver_10.3/server/lib/wljmsclient.jar QueueSend.java
javac
-classpath
.:/root/Oracle/Middleware/wlserver_10.3/server/lib/wljmsclient.jar QueueReceive.java
Execute both
the classes in separate command prompts like
Queue Send
java
-classpath .:/root/Oracle/Middleware/wlserver_10.3/server/lib/wljmsclient.jar QueueReceive t3://localhost:7001
JMS Ready To
Receive Messages (To quit, send a "quit" message).
Message
Received: hello
Message
Received: too much
Queue Receive
java
-classpath .:/root/Oracle/Middleware/wlserver_10.3/server/lib/wljmsclient.jar QueueSend t3://localhost:7001
Enter
message ("quit" to quit):
hello
JMS Message
Sent: hello
Enter
message ("quit" to quit):
too much
JMS Message
Sent: too much
Enter
message ("quit" to quit):
More To Come
, Happy learning J