The Java Message Service (JMS) API provides a common way for Java programs to create, send, receive and read an enterprise messaging system's messages.
JMS ApplicationsA JMS application is composed of the following parts:
JMS providers differ significantly in their implementations of underlying messaging technology. There are also major differences in how a JMS provider's system is installed and administered.
For JMS clients to be portable, they must be isolated from these proprietary aspects of a provider. This is done by defining JMS administered objects that are created and customised by a provider's administrator and later used by clients. The client uses them through JMS interfaces that are portable. The administrator creates them using provider-specific facilities.
There are two types of JMS administered objects:
ConnectionFactory
- the object a client uses to create a connection with a JMS providerDestination
- the object a client uses to specify the destination of messages it is sending and the source of messages it receivesAdministered objects are placed by an administrator in a JNDI (Java Naming and Directory Interface) namespace. A JMS client typically notes in its documentation the JMS administered objects it requires and how the JNDI names of these objects should be provided to it.
Two Messaging StylesJMS supports two styles of messaging:
These two styles represent two of the dominant approaches to messaging currently in use.
JMS APIsFor historical reasons JMS offers four alternative sets of interfaces for sending and receiving messages:
Each API offers a different set of interfaces for connecting to a JMS provider and for sending and receiving messages. However they all share a common set of interfaces for representing messages and message destinations and to provide various utility features.
All interfaces are in the javax.jms
package.
The main interfaces common to multiple APIs are as follows:
Message
, BytesMessage
, MapMessage
, ObjectMessage
, StreamMessage
and TextMessage
- a message sent to or received from a JMS provider.Queue
- an administered object that encapsulates the identity of a message destination for point-to-point messagingTopic
- an administered object that encapsulates the identity of a message destination for pub/sub messaging.Destination
- the common supertype of Queue
and Topic
The main interfaces provided by the classic API are as follows:
ConnectionFactory
- an administered object used by a client to create a Connection
. This interface is also used by the simplified API.Connection
- an active connection to a JMS providerSession
- a single-threaded context for sending and receiving messagesMessageProducer
- an object created by a Session that is used for sending messages to a queue or topicMessageConsumer
- an object created by a Session that is used for receiving messages sent to a queue or topicThe simplified API provides the same messaging functionality as the classic API but requires fewer interfaces and is simpler to use. The main interfaces provided by the simplified API are as follows:
ConnectionFactory
- an administered object used by a client to create a JMSContext
. This interface is also used by the classic API.JMSContext
- an active connection to a JMS provider and a single-threaded context for sending and receiving messagesJMSProducer
- an object created by a JMSContext
that is used for sending messages to a queue or topicJMSConsumer
- an object created by a JMSContext
that is used for receiving messages sent to a queue or topicAlthough the domain-specific API remains part of JMS for reasons of backwards compatibility it should be considered to be completely superseded by the classic and simplified APIs.
The main interfaces provided by the domain-specific API for point-to-point messaging are as follows:
QueueConnectionFactory
- an administered object used by a client to create a QueueConnection
.QueueConnection
- an active connection to a JMS providerQueueSession
- a single-threaded context for sending and receiving messagesQueueSender
- an object created by a QueueSession
that is used for sending messages to a queueQueueReceiver
- an object created by a QueueSession
that is used for receiving messages sent to a queueThe main interfaces provided by the domain-specific API for pub/sub messaging are as follows:
TopicConnectionFactory
- an administered object used by a client to create a TopicConnection
.TopicConnection
- an active connection to a JMS providerTopicSession
- a single-threaded context for sending and receiving messagesTopicPublisher
- an object created by a TopicSession
that is used for sending messages to a topicTopicSubscriber
- an object created by a TopicSession
that is used for receiving messages sent to a topicThe term consume is used in this document to mean the receipt of a message by a JMS client; that is, a JMS provider has received a message and has given it to its client. Since JMS supports both synchronous and asynchronous receipt of messages, the term consume is used when there is no need to make a distinction between them.
The term produce is used as the most general term for sending a message. It means giving a message to a JMS provider for delivery to a destination.
Developing a JMS ApplicationBroadly speaking, a JMS application is one or more JMS clients that exchange messages. The application may also involve non-JMS clients; however, these clients use the JMS provider's native API in place of the JMS API.
A JMS application can be architected and deployed as a unit. In many cases, JMS clients are added incrementally to an existing application.
The message definitions used by an application may originate with JMS, or they may have been defined by the non-JMS part of the application.
Developing a JMS ClientA typical JMS client using the classic API executes the following JMS setup procedure:
ConnectionFactory
objectDestination
objectsConnection
object with message delivery inhibitedSession
objectsMessageProducer
and MessageConsumer
objects neededConnection
to start delivery of messagesIn contrast, a typical JMS client using the simplified API does the following:
ConnectionFactory
objectDestination
objectsConnectionFactory
to create a JMSContext
objectJMSContext
to create the JMSProducer
and JMSConsumer
objects needed.At this point a client has the basic JMS setup needed to produce and consume messages.
Package SpecificationJava Message Service 2.0 specificationRelated Documentation
Java Platform, Enterprise Edition (Java EE) Technical Documentation
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3