Friday Jun 07, 2013

New Messaging Features in JMS 2.0

Part Two of Nigel Deakin’s series on JMS 2.0 (Java Message Service), titled “What's New in JMS 2.0, Part Two—New Messaging Features,” is now up on otn/java. While Part One looked at new ease-of-use features introduced in JMS 2.0, Part Two explores five important new messaging features.

First, a new kind of topic subscription called a shared subscription now allows for multiple consumers on the same topic subscription.

Second, developers can now specify a delivery delay on a message so that the JMS provider will not deliver the message until after the specified delivery delay has elapsed

Third, with JMS 2.0, users can send a message asynchronously. As Deakin explains, “This feature is available for applications running in Java SE or the Java EE application client container. It is not available to applications that run in the Java EE Web or EJB container.” According to Deakin, “When a message is sent asynchronously, the send method sends the message to the server and then returns control to the application without waiting for a reply from the server. Instead of being blocked unproductively while the JMS client waits for a reply, the application can do something useful, such as sending a further message or performing some processing.”

Deakin explains that there are two main ways in which you might use an asynchronous send in an application:

* To allow the application to do something else (such as update the display or write to a database) during the interval when it would otherwise be waiting for a reply from the server

* To allow a large number of messages to be sent in succession without waiting for a reply from the server after each message

Fourth, JMS 2.0 allows applications that receive a message to determine how many times the message has been redelivered.

And finally, a Java EE application that needs to receive messages asynchronously does so using an MDB, or message-driven bean, which is configured by specifying a number of configuration properties. Check out the article here.

Wednesday May 22, 2013

What's New in JMS 2.0: Ease of Use

A new article by Oracle’s Nigel Deakin, up on otn/java, titled “What's New in JMS 2.0, Part One: Ease of Use,” demonstrates ways in which JMS 2.0 enables developers to send and receive messages while writing less code. Some features of JMS 2.0, part of Java EE 7, and can be deployed in Java EE Web or EJB applications, while others can only be used standalone in a Java SE environment.

Deakin writes:

“The single biggest change in JMS 2.0 is the introduction of a new API for sending and receiving messages that reduces the amount of code a developer must write. For applications that run in a Java EE application server, the new API also supports resource injection. This allows the application server to take care of the creation and management of JMS objects, simplifying the application even further…”

The new API, known as the “simplified” API, is simpler and easier to use than the existing JMS 1.1 API, now known as the “classic” API.

Deakin describes the new API as follows:

“The simplified API consists of three new interfaces: JMSContext, JMSProducer, and JMSConsumer:

* JMSContext replaces the separate Connection and  Session objects in the classic API with a single object.

* JMSProducer is a lightweight replacement for the MessageProducer object in the classic API. It allows message delivery options, headers, and properties to be configured using method chaining (sometimes known as a builder pattern).

* JMSConsumer replaces the MessageConsumer object in the classic API and is used in a similar way.”

Developers can now choose between the two APIs and have access to both the classic and new features. Stay tuned for Part Two, in which Deakin will explore new messaging features in JMS 2.0.

Check out Part One here.

About

Insider News from the Java Team at Oracle!

duke
javeone logo
Links


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
2
5
6
7
12
13
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today