Java Message Service
Encyclopedia : J : JA : JAV : Java Message Service
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 specification developed under the Java Community Process as JSR 914. As of 2006, the current version is JMS 1.1.
Version history
Architecture
JMS elements
JMS consists of several elements:
- JMS provider
- An implementation of the JMS interface for a Message Oriented Middleware (MOM). Providers are implemented as either a Java JMS implementation or an adapter to a non-Java MOM.
- JMS client
- A Java-based application or object that produces and/or consumes messages.
- JMS producer
- A JMS client that creates and sends messages.
- JMS consumer
- A JMS client that receives messages.
- JMS message
- An object that contains the data being transferred between JMS clients.
- JMS queue
- A staging area that contains messages that have been sent and are waiting to be read. As the name queue suggests, the messages are delivered in the order sent. A message is removed from the queue once it has been read.
- JMS topic
- A distribution mechanism for publishing messages that are delivered to multiple subscribers.
JMS models
The JMS API supports two models:
- point-to-point or queueing model
- publish and subscribe model
- Only one consumer will get the message
- The producer does not have to be running at the time the receiver consumes the message, nor does the receiver need to be running at the time the message is sent
- Every message successfully processed is acknowledged by the receiver
- Multiple consumers can get the message
- There is a timing dependency between publishers and subscribers. Publisher has to create a subscription in order for clients to be able to subscribe. Subscriber has to remain continuously active to receive messages, unless it has established a durable subscription. In that case, messages published while the subscriber is not connected will be redistributed whenever it will reconnect.
JMS API
The JMS API is provided in the Java package .
An administered object that a client uses to create a connection to the JMS provider. JMS clients access the connection factory through portable interfaces so the code does not need to be changed if the underlying implementation changes. Administrators configure the connection factory in the Java Naming and Directory Interface (JNDI) namespace so that JMS clients can look them up. Depending on the type of message, users will use either a queue connection factory or topic connection factory.
interface
Once a connection factory is obtained, a connection to a JMS provider can be created. A connection represents a communication link between the application and the messaging server. Depending on the connection type, connections allow users to create sessions for sending and receiving messages from a queue or topic.
interface
An administered object that encapsulates the identity of a message destination, which is where messages are delivered and consumed. It is either a queue or a topic. The JMS administrator creates these objects, and users discover them using JNDI. Like the connection factory, the administrator can create two types of destinations: queues for Point-to-Point and topics for Publish/Subscribe.
interface
An object created by a session. It receives messages sent to a destination. The consumer can receive messages synchronously (blocking) or asynchronously (non-blocking) for both queue and topic-type messaging.
interface
An object created by a session that sends messages to a destination. The user can create a sender to a specific destination or create a generic sender that specifies the destination at the time the message is sent.
interface
An object that is sent between consumers and producers; that is, from one application to another. A message has three main parts:
- A message header (required): Contains operational settings to identify and route messages
- A set of message properties (optional): Contains additional properties to support compatibility with other providers or users. It can be used to create custom fields or filters (selectors).
- A message body (optional): Allows users to create five types of messages (text message, map message, bytes message, stream message, and object message).
The message interface is extremely flexible and provides numerous ways to customize the contents of a message.interface
Represents a single-threaded context for sending and receiving messages. A session is single-threaded so that messages are serialized, meaning that messages are received one-by-one in the order sent. The benefit of a session is that it supports transactions. If the user selects transaction support, the session context holds a group of messages until the transaction is committed, then delivers the messages. Before committing the transaction, the user can cancel the messages using a rollback operation. A session allows users to create message producers to send messages, and message consumers to receive messages.
JMS Provider Implementations
In order to use JMS, one must have a JMS provider that can manage the sessions and queues. There are open source as well as proprietary providers.
The open source providers include:
- [Open Message Queue] from Sun Microsystems
- ActiveMQ
- [JBoss Messaging] and [JBossMQ] from JBoss Inc.
- [Joram]
- [MantaRay] from Coridan
- OpenJMS from [The OpenJMS Group]
The proprietary providers include:
- [Axway Messaging System] from Axway Software
- BEA WebLogic Server JMS from BEA Systems
- [EMS] from TIBCO Software
- [FioranoMQ™ 2006]
- GigaSpaces from [GigaSpaces Technologies]
- WebSphere MQ from IBM (formerly MQSeries)
- iBus from [Softwired 2006]
- IONA JMS from IONA Technologies
- IQManager from [SeeBeyond] (Acquired in August 2005 by Sun Microsystems)
- JMS+ from webMethods - http://www.webmethods.com
- Nirvana from [my-channels]
- [Oracle Enterprise Messaging Services (OEMS)] from Oracle Corporation
- SonicMQ from Sonic Software
- [Sun Java System Message Queue] from Sun Microsystems
- SwiftMQ from [SwiftMQ]
An exhaustive comparison matrix of JMS providers is available at: http://www.theserverside.com/reviews/matrix.tss
If you plan to run your application in a server cluster, you should check with provider if their implementation supports load balancing and/or failover.
External links
- [Sun's JMS Overview]
- [JSR 914] (JMS 1.0 and 1.1)
- [GigaSpaces Technologies JavaSpaces approach to JMS]
- [Generic Resource Adapter for JMS]
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
