Topics

Featured in Development

Peter Alvaro talks about the reasons one should engage in language design and why many of us would (or should) do something so perverse as to design a language that no one will ever use. He shares some of the extreme and sometimes obnoxious opinions that guided his design process.

Featured in AI, ML & Data Engineering

Today on The InfoQ Podcast, Wes talks with Katharine Jarmul about privacy and fairness in machine learning algorithms. Jarul discusses what’s meant by Ethical Machine Learning and some things to consider when working towards achieving fairness. Jarmul is the co-founder at KIProtect a machine learning security and privacy firm based in Germany and is one of the three keynote speakers at QCon.ai.

Featured in Culture & Methods

Organizations struggle to scale their agility. While every organization is different, common patterns explain the major challenges that most organizations face: organizational design, trying to copy others, “one-size-fits-all” scaling, scaling in siloes, and neglecting engineering practices. This article explains why, what to do about it, and how the three leading scaling frameworks compare.

What's New in JMS 2.0?

Well the long awaited Java EE 7 is finally here, and with it comes JMS 2.0, the first upgrade to JMS in over a decade.

Most notable in the modern JMS specification is the willowy expressiveness of what Oracle calls the "Simplified" API. For example the new API for sending and receiving messages eliminates most of the boilerplate and dramatically reduces the amount of code required. If you're running in an application server the new API supports resource injection, allowing the application server to manage the JMS objects, which further simplifies the application.

The framework is completely backward compatible, so you are free to continue using your legacy code while implementing the Simplified API for your new code. There are no plans to deprecate the old API.

JMS 2.0 is part of the Java EE 7 platform but can also be used as a standalone Java SE platform, although not all features are available in both modes.

Let's analyze the changes. First up is the use of Java 7 "try-with-resources", in line 19. The new AutoCloseable JMSContext replaces both the old Connection class and Session class. When included in a try clause (line 19) all of the original "try" setup code (lines 4,11,12,13) is obviated. The message creation is also now implicit, so the resulting code is obviously a greatly trimmed down version of the original.

Also the old checked JMSException has now been replaced with the unchecked JMSRuntimeException, so it no longer needs to be explicitly caught.

That is the message sender code. The message receiver code is similarly terse.

The Simplified API is just one part of the new JMS 2.0 API. In addition there are several new semantic enhancements. There is now support for features such as:

Asynchronous send mode - In contrast to the traditional synchronous mode that blocks until an acknowledgement is received from the server, asynchronous mode returns immediately without blocking. Once the acknowledgement is received, an asynchronous callback is invoked. Asynchronous mode is supported on both the new JMSProducer and its legacy counterpart MessageProducer. For example, your application can define a CompletionListener with the following interface:

Delayed message delivery - Allows a JMS client to schedule the future delivery of a message providing support for deferred processing, such as at the end of day. The application can set the minimum time in milliseconds that a message should be retained by the messaging system before delivery to a consumer.

The API is similar for MessageProducer and JMSProducer:

For MessageProducer:

public void setDeliveryDelay(long deliveryDelay)

For JMSProducer:

public JMSProducer setDeliveryDelay(long deliveryDelay)

Sharing of the same topic subscription allows scalable consumption of messages from a topic subscription.
New methods are provided for non-durable subscriptions.