JMS 2.0 Public Review Draft
JMS 2.0 has now been released. This page is retained here as a historical record. See also the JMS 2.0 Final Release page.
The JMS 2.0 Public Review Draft is now published. The specification and API documentation may be downloaded from the JCP website here. The formal review period began on 3 January 2013 and ends on 4 February 2013.
What’s new in JMS 2.0?
A full list of the new features, changes and clarifications introduced in JMS 2.0 is given in the specification. See section B.5 “Version 2.0” of the “Change history” appendix. Here is a summary:
The JMS 2.0 specification now requires JMS providers to implement both P2P and Pub-Sub.
The following new messaging features have been added in JMS 2.0:
- Delivery delay: a message producer can now specify that a message must not be delivered until after a specified time interval.
- New send methods have been added to allow an application to send messages asynchronously.
- JMS providers must now set the JMSXDeliveryCount message property.
The following change has been made to aid scalability:
- Applications are now permitted to create multiple consumers on the same durable or non-durable topic subscription. In previous versions of JMS only a single consumer was permitted.
Several changes have been made to the JMS API to make it simpler and easier to use:
Sessionand other objects with a
closemethod now implement the
java.jang.AutoCloseableinterface to allow them to be used in a Java SE 7 try-with-resources statement.
- A new “simplified API” has been added which offers a simpler alternative to the standard API, especially in Java EE applications.
- New methods have been added to create a session without the need to supply redundant arguments.
- Although setting client ID remains mandatory when creating an unshared durable subscription, it is optional when creating a shared durable subscription.
- A new method
getBodyhas been added to allow an application to extract the body directly from a Message without the need to cast it first to an appropriate subtype.
A new chapter has been added which describes some additional restrictions and behaviour which apply when using the JMS API in the Java EE web or EJB container. This information was previously only available in the EJB and Java EE platform specifications.
A new chapter has been added which adds a new requirement for a JMS provider to include a resource adapter, and which defines a number of standard endpoint activation properties.
New methods have been added to
Session which return a
MessageConsumer on a durable topic subscription. Applications could previously only obtain a domain-specific
TopicSubscriber, even though its use was discouraged.
The specification has been clarified in various places.
JMS 2.0 demonstration examples
A NetBeans project which demonstrates some new features of JMS 2.0 may be downloaded as a zip or checked out from the project’s subversion repository here. An earlier version was demonstrated at JavaOne 2012.
The latest version of this demonstration has been tested with GlassFish 4.0 nightly build 78. If you have problems running with a later version, please let us know.
This demonstration shows
- Use of the JMS 2.0 simplified API using application-managed
- Use of the JMS 2.0 API using Java EE container-managed (injected)
- Use of the new
receiveBodymethod to synchronously receive a message and return its body in a single method call
- Use of the new
getBodymethod to return the body of a
Messagewithout the need to cast it to a more specific message type