New in JMS 2.0 . . .

This post lists ALL of the new APIs (interfaces/classes/annotations etc.) introduced in JMS 2.0 (part of the Java EE 7 platform). These have been categorized as follows

  • API simplification
  • Ease of use
  • Exception Handling
  • Miscellaneous

Here is a quick summary along with some code snippets

API simplification


Simpler abstraction on top of Connection and Session objects which eliminates the need for interacting with these classes/interfaces in order to send/receive messages.


Used during JMSContext injection to specify the JNDI name of the JMS ConnectionFactory

JMSProducer and JMSConsumer

As the name suggests, a JMSProducer and JMSConsumer encapsulate the process of sending JMS messages to and from destinations (topics and queues), respectively. Instances to these objects can be obtained from the JMSContext object and they are important from an API ease-of-use perspective. Here is a ‘fluent’ API example


Transactional equivalent of the vanilla JMSContext object. The implementation of this interface provides support for JTA within JMS

Ease of use

These annotations empower less reliance on manual/administrative configuration and drive automated deployment of Java EE applications. These are perfect examples of ‘configuration as code’ and invaluable in Cloud (PaaS) deployment scenarios

JMSConnectionFactoryDefinition and JMSConnectionFactoryDefinitions

Specify the JNDI name of one/multiple JMS ConnectionFactory object. This resource will be automatically provisioned at deployment time

JMSDestinationDefinition and JMSDestinationDefinitions

Specify the JNDI name of one/more JMS Destinations (queues/topics). This resource will be automatically provisioned at deployment time

Exception Handling

JMS 1.1 and earlier versions did not have a notion of unchecked exceptions. From JMS 2.0, JMSRuntimeException has been introduced to act as the base/parent from which all other unchecked exceptions have been extended. Here is a list all the new exceptions introduced in JMS 2.0 (these are mostly unchecked versions of their checked counterparts)

  • JMSRuntimeException
  • IllegalStateRuntimeException
  • InvalidClientIDRuntimeException
  • InvalidDestinationRuntimeException
  • InvalidSelectorRuntimeException
  • JMSSecurityRuntimeException
  • MessageFormatRuntimeException
  • MessageNotWriteableRuntimeException
  • ResourceAllocationRuntimeException
  • TransactionInProgressRuntimeException
  • TransactionRolledBackRuntimeException



Used to secure access to JMS provider before attempting any operations using an injected JMSContext object


Specifies session mode to be used during JMSContext injection

That’s it for the new stuff in JMS 2.0 from an API perspective.

Cheers !

About Abhishek

Currently working as a Senior Product Manager in the Oracle Cloud Application Development team with a focus on Oracle Cloud PaaS portfolio. When not hovering in the clouds, I stay grounded with Java EE
This entry was posted in Java EE and tagged , , , . Bookmark the permalink.

5 Responses to New in JMS 2.0 . . .

  1. Pingback: Automated provisioning of JMS resources in Java EE 7 | Thinking in Java (at least trying to!)

  2. Pingback: Automated Provisioning of JMS Resources in Java EE 7 -

  3. Pingback: Automated Provisioning of JMS Resources in Java EE 7 | JAVA

  4. Pingback: Automated Provisioning of JMS Resources in Java EE 7 | Dinesh Ram Kali.

  5. Pingback: Automated Provisioning of JMS Resources in Java EE 7 | Voxxed

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s