Skip to Main Content
Enterprise JavaBeans 3.1, 6th Edition
book

Enterprise JavaBeans 3.1, 6th Edition

by Andrew Lee Rubinger, Bill Burke
September 2010
Intermediate to advanced content levelIntermediate to advanced
766 pages
18h 35m
English
O'Reilly Media, Inc.
Content preview from Enterprise JavaBeans 3.1, 6th Edition

Appendix E. Message-Driven EJB: Status Update Listeners Example

Description

Session beans, as we’ve seen up to this point, are best suited for servicing client requests. Many enterprise systems, however, use a messaging layer to asynchronously pass requests from application to application. In Java, we use the Java Message Service abstraction to push/pull messages via Queues and Topics, and the integration of JMS with EJB is the message-driven bean.

In this example, we implement social networking status updates via a consumer/publisher Topic. Anyone listening on the Topic will receive incoming status updates, and we create 2 listeners: 1 simple one to log out to the command-line or logfile, and another to push the updates to Twitter.

Note: Set the environment variables below before running to take advantage of the Twitter updates while running the tests.

OREILLY_EJB_BOOK_CH08_TWITTER_USERNAME
OREILLY_EJB_BOOK_CH08_TWITTER_PASSWORD

Additionally, in this example we show how the use of a single JVM for the test and the server can be used to enable shared memory locking (i.e., java.util.concurrent) to reliably test that asynchronous components have completed as expected.

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

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
JavaServer Faces

JavaServer Faces

Hans Bergsten
EJB 3 Developer Guide

EJB 3 Developer Guide

Michael Sikora

Publisher Resources

ISBN: 9781449399139Errata Page