Java Message Service
The Java Message Service (JMS) API is a Java message-oriented middleware API for sending messages between two or more clients. It is an implementation to handle the producer–consumer problem. JMS is a part of the Java Platform, Enterprise Edition (Java EE), and was defined by a specification developed at Sun Microsystems, but which has since been guided by the Java Community Process. It is a messaging standard that allows application components based on Java EE 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.
General idea of messaging
Messaging is a form of loosely coupled distributed communication, where in this context the term 'communication' can be understood as an exchange of messages between software components. Message-oriented technologies attempt to relax tightly coupled communication (such as TCP network sockets, CORBA or RMI) by the introduction of an intermediary component. This approach allows software components to communicate with each other indirectly. Benefits of this include message senders not needing to have precise knowledge of their receivers.
The advantages of messaging include the ability to integrate heterogeneous platforms, reduce system bottlenecks, increase scalability, and respond more quickly to change.
- JMS 1.0
- JMS 1.0.1 (October 5, 1998)
- JMS 1.0.1a (October 30, 1998)
- JMS 1.0.2 (December 17, 1999)
- JMS 1.0.2a (December 23, 1999)
- JMS 1.0.2b (August 27, 2001)
- JMS 1.1 (April 12, 2002)
- JMS 2.0 (May 21, 2013)
- JMS 2.0a (March 16, 2015)
The following are JMS elements:
- JMS provider
- An implementation of the JMS interface for message-oriented middleware (MOM). Providers are implemented as either a Java JMS implementation or an adapter to a non-Java MOM.
- JMS client
- An application or process that produces and/or receives messages.
- JMS producer/publisher
- A JMS client that creates and sends messages.
- JMS consumer/subscriber
- 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 (by only one consumer). As the name queue suggests, the messages are delivered in the order sent. A JMS queue guarantees that each message is processed only once.
- JMS topic
- A distribution mechanism for publishing messages that are delivered to multiple subscribers.
The JMS API supports two distinct models:
Under the point-to-point messaging system, messages are routed to individual consumers who maintain queues of incoming messages. This messaging type is built on the concept of message queues, senders, and receivers. Each message is addressed to a specific queue, and the receiving clients extract messages from the queues established to hold their messages. While any number of producers can send messages to the queue, each message is guaranteed to be delivered, and consumed by one consumer. Queues retain all messages sent to them until the messages are consumed or until the messages expire. If no consumers are registered to consume the messages, the queue holds them until a consumer registers to consume them.
The publish-and-subscribe model supports publishing messages to a particular message "topic". Subscribers may register interest in receiving messages published on a particular message topic. In this model, neither the publisher nor the subscriber knows about each other. A good analogy for this is an anonymous bulletin board.
- Zero or more consumers will receive the message.
- There is a timing dependency between publishers and subscribers. The publisher has to create a message topic for clients to subscribe. The 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 reconnects.
JMS provides a way of separating the application from the transport layer of providing data. The same Java classes can be used to communicate with different JMS providers by using the Java Naming and Directory Interface (JNDI) information for the desired provider. The classes first use a connection factory to connect to the queue or topic, and then use populate and send or publish the messages. On the receiving side, the clients then receive or subscribe to the messages.
RFC 6167 defines a
jms: URI scheme for the Java Message Service.
To use JMS, one must have a JMS provider that can manage the sessions, queues and topics. Starting from Java EE version 1.4, a JMS provider has to be contained in all Java EE application servers. This can be implemented using the message inflow management of the Java EE Connector Architecture, which was first made available in that version.
The following is a list of common JMS providers:
- Amazon SQS's Java Messaging Library
- Apache ActiveMQ
- Apache Qpid, using AMQP
- IBM MQ (formerly MQSeries, then WebSphere MQ)
- IBM WebSphere Application Server's Service Integration Bus (SIBus)
- JBoss Messaging and HornetQ from JBoss
- JORAM from the OW2 Consortium
- Open Message Queue from Oracle
- OpenJMS from the OpenJMS Group
- Oracle WebLogic Server and Oracle AQ
- RabbitMQ from Pivotal Software
- Message Driven Beans
- Message queue — the concept underlying JMS
- Service-oriented architecture
- Messaging technologies that do not implement the JMS API include:
- Advanced Message Queuing Protocol (AMQP) — standardized message queue protocol with multiple independent implementations
- Data Distribution Service (DDS) — An Object Management Group (OMG) standardized real-time messaging system with over ten implementations that have demonstrated interoperability between publishers and subscribers
- Microsoft Message Queuing — similar technology, implemented for .NET Framework
- Curry, Edward. 2004. "Message-Oriented Middleware"[yes|permanent dead link|dead link}}]. In Middleware for Communications, ed. Qusay H Mahmoud, 1-28. Chichester, England: John Wiley and Sons. doi:10.1002/0470862084.ch1. ISBN:978-0-470-86206-3
- "JSR 914: Java Message Service (JMS) API". https://jcp.org/en/jsr/detail?id=914.
- Java Message Service (JMS)
- Richards et al, pages 3–5
- "Java Message Service". Sun Microsystems. October 5, 1998. http://java.sun.com/products/jms/jms-101-spec.pdf.
- "Java Message Service Documentation". Sun Microsystems. October 30, 1998. http://java.sun.com/products/jms/docs.html.
- "Java Message Service Source - Version 1.0.1a" (ZIP). Sun Microsystems. October 29, 1998. http://www.javasoft.com/products/jms/jms-101a-src.zip.
- "Java Message Service". Sun Microsystems. November 9, 1999. http://java.sun.com/products/jms/jms1_0_2-spec.pdf.
- "Java Message Service Documentation". Sun Microsystems. December 23, 1999. http://java.sun.com/products/jms/docs.html.
- "Java Message Service". Sun Microsystems. August 27, 2001. http://download.oracle.com/otn-pub/jcp/7543-jms-1.0.2b-spec-oth-JSpec/jms-1_0_2b-spec.pdf.
- "Java Message Service". Sun Microsystems. April 12, 2002. https://github.com/javaee/jms-spec/raw/9383d33ff79a156d09fb5c9c0ccdfd6b844b1d54/jms1.1/specification/jms-1_1-fr-spec.pdf.
- "Java Message Service". Oracle. March 20, 2013. https://github.com/javaee/jms-spec/raw/9383d33ff79a156d09fb5c9c0ccdfd6b844b1d54/jms2.0/specification/word/JMS20.pdf.
- "JMS 2.0 Final Release". June 9, 2017. https://javaee.github.io/jms-spec/pages/JMS20FinalRelease.
- "Java Message Service". Oracle. March 10, 2015. https://github.com/javaee/jms-spec/raw/9383d33ff79a156d09fb5c9c0ccdfd6b844b1d54/jms2.0a/specification/word/JMS20.pdf.
- "JMS 2.0 errata release (Rev a)". July 5, 2017. https://javaee.github.io/jms-spec/pages/JMS20RevA.
- "JSR 343: Java Message Service 2.0". https://jcp.org/en/jsr/detail?id=343.
- "Apache Qpid™: Open Source AMQP Messaging". http://qpid.apache.org/.
- Wallis, Graham. "Choosing a messaging system: WebSphere MQ vs. the WebSphere Application Server Service Integration Bus". IBM developerWorks. http://www.ibm.com/developerworks/websphere/library/techarticles/1109_wallis/1109_wallis.html.
- Richards, Mark; Richard Monson-Haefel; David A. Chappell (2009). Java Message Service, Second Edition. O'Reilly. ISBN 978-0-596-52204-9.
- JSR 343: Java Message Service 2.0
javax.jmsAPI Javadoc documentation
- Oracle's Java EE 7 JMS tutorial
- A historical comparison matrix of JMS providers