C.3 Messaging Integration Patterns

Content Aggregator Pattern

Goal

To allow a single handler to easily process messages from a variety of sources that have similar content but different formats.

Participants

Multiple senders

Send messages to the content aggregator.

Content aggregator

Reads each message and creates a new message in a common format.

Message handler

Processes the messages.

Interactions

Senders send messages to the content aggregator. The aggregator reads each message and creates a new message in a common format. The new message is sent on to a single handler.

Content-Based Routing Pattern

Goal

Provide a single point of receipt for messages associated with a particular use case, even if the use case will be handled by different backend systems depending on the content of the request (Figure C-3).

Figure C-3. Content-based routing
figs/j2ee_ac03.gif

Participants

Sender

Sends the message to the router.

Message

Contains the content.

Content router

Examines the content and determines which handler should be used.

Handlers

Process the message.

Interactions

The sender sends a message to the router. The router examines the message content and determines which handler should be used to process it. This check may be assisted by an external resource, such as a directory server. The router then dispatches the message to the appropriate handler.

Control Bus Pattern

Goal

To provide a centralized interface for asynchronously managing multiple systems and multiples nodes of single systems (Figure C-4).

Figure C-4. Control bus spanning three applications with logging and control channels
figs/j2ee_ac04.gif

Participants

Administrative clients

Read event messages.

Control bus channel

Sends event messages and receives control messages.

Applications

Share a single control bus channel.

Interactions

The applications being controlled share a single control bus channel to send event messages and receive control messages. Event messages are read off the channel by administrative clients, which include administration consoles and logging servers. The controlled applications monitor the control bus channel for command messages.

Notes

Command messages on the channel can take two forms: global and targeted. All applications must be compatible with the command message format used on the bus. This compatibility allows an administrative application to send global commands as well as commands to individual applications. Event messages, likewise, must share a common format, allowing administrative and logging clients to easily process the information provided by each application.

Pipes and Filters Pattern

Goal

To spread processing of a message across multiple consumers, allowing flexible workflow, distribution of processing, and easy reuse (Figure C-5).

Figure C-5. Pipes and filters collaboration
figs/j2ee_ac05.gif

Participants

Sender

Sends the message.

Message

Contains the content.

Multiple message handlers

Examine and process the message.

Interactions

The sender transmits a message to the first message handler in the processing chain. The first handler in the chain examines the message and performs whatever processing is required. It then forwards the message to another handler for further processing. Each handler is required to determine the appropriate next destination.

Notes

For more on implementing flexible workflows, see the Service to Worker pattern.



J2EE Design Patterns
J2EE Design Patterns
ISBN: 0596004273
EAN: 2147483647
Year: 2006
Pages: 113

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net