The Java Message Service (JMS) API is a Java Message Oriented Middleware (MOM) API for sending messages between two or more clients. JMS is a part of the Java Platform, Enterprise Edition, and is defined by a specification developed under the Java Community Process as JSR 914. It is a messaging standard that allows application components based on the Java Enterprise Edition (JEE) to create, send, receive, and read messages. It allows the communication between different components of a distributed application to be loosely coupled, reliable, and asynchronous.
JMS Connection Factories:
Java Message Service (JMS) connection factories are objects that allow an application to create other JMS objects programmatically.
Destination Resources:
JMS destinations serve as the repositories for messages.
There are two types of destination resources :
Queue:
It ensures the delivery of messages to exactly one recipient. It is a one to one communication.
Topic:
It ensures the delivery of messages to multiple recipients. It is a one to many communication.
Example:
In this example we are going to create a Connection Factory and Queue as a destination resource.
Step1:
Click on JMS Resources and click Connection Factories.
Step2:
Click on New to create a new Connection Factory.
Step3:
Enter the Pool Name as jms/tConnectionFactory.
Select the Resource Type as javax.jms.ConnectionFactory.
Step4:
Select the server as a target.
Step5:
Click on Destination Resources and click on New to create a new Destination Resource.
Step6:
Enter JNDI Name as jms/tQueue
Enter Physical Destination Name as tQueue
Select the Resource Type as javax.jms.Queue
Step7:
Select the server as the target.
Step8:
That’s it; The configuration of JMS Resources is completed. Now let us test the configuration.
Open the asadmin utility and type the following command
asadmin> list-jms-resources --port 4848
Deploy the application (download) in admin server/server.
Step9:
Click on Applications and click the jms application.
Step10:
Click on Launch.
Step11:
Click on the first link.
Step12:
Enter the message as hello glassfish and click on send the message.
Step13:
Navigate to the following directory:
Glassfish3\glassfish\domains\DomainName\logs\server.txt
Open the server.txt file, you can see that the message is received by the Message Bean TMDB.
0 comments:
Post a Comment