Skip to Main Content
Java Message Service, 2nd Edition
book

Java Message Service, 2nd Edition

by Mark Richards, Richard Monson-Haefel, David A Chappell
May 2009
Intermediate to advanced content levelIntermediate to advanced
330 pages
10h 34m
English
O'Reilly Media, Inc.
Content preview from Java Message Service, 2nd Edition

Message-Driven Beans

Although session beans and web components can act as JMS producers, these components can only consume JMS messages synchronously using one of the MessageConsumer.receive() methods. Calling the receive() methods causes the JMS client to block on the currently running thread and wait for a message.[12] These methods are used to consume messages synchronously, whereas MessageListener objects are used to consume messages asynchronously.

Only the message-driven bean and application client components can both produce and consume asynchronous messages. The web and session components cannot act as asynchronous JMS consumers because they are driven by synchronous request/reply protocols, not asynchronous messages. Web components respond to HTTP requests while session beans respond to Java RMI-IIOP requests.

The fact that neither web components nor session beans can asynchronously consume JMS messages was one of the things that originally led to development of the message-driven bean. The MDB provides Java EE developers with a server-side JMS consumer that can consume asynchronous messages, something that wasn’t supported in the early versions of Java EE.

While most JMS vendors provide the message-brokering facilities for routing messages from producers to consumers, the responsibility for implementing JMS clients is left to the application developer. In many cases, the JMS clients that consume and process messages need a lot of infrastructure in order to be robust, secure, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reactive Systems in Java

Reactive Systems in Java

Clement Escoffier, Ken Finnigan
Java 8 in Action

Java 8 in Action

Mario Fusco, Alan Mycroft, Raoul-Gabriel Urma
The Well-Grounded Java Developer, Second Edition

The Well-Grounded Java Developer, Second Edition

Benjamin Evans, Martijn Verburg, Jason Clark

Publisher Resources

ISBN: 9780596802264Supplemental ContentErrata Page