Name
Event-Driven Consumer Pattern
Goal
To deliver messages to a client as quickly as possible, while minimizing the complexity of the code, the developer must assemble to handle messages.
Participants
- Message server
Receives incoming messages.
- Application server
Communicates with the message server and retrieves new messages.
- Client code
Performs the actual processing, based on calls from the application server.
Interactions
Incoming messages are delivered to the message server. The application server communicates with the message server and retrieves new messages destined for a particular client. When new messages arrive, the application server calls appropriate client code to process them.
Notes
Message-driven EJBs implement the Event-Driven Consumer pattern. JMS
also supports implementing event-driven consumers directly. JavaMail
supports event-driven consumers via the
FolderListener
interface, although we do not
recommend it. Most event-driven consumer implementations simply push
implementation to the application server/application framework level,
while still implementing a polling consumer behind the scenes.
Get J2EE Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.