The scatter gather model chosen was taken from the ESB sample but extended to allow advanced correlation, abstraction of the broker and dispatcher components and fault management.
Walking the diagram above (left to right) the following components are invoked:
Abstract Broker
This component is abstract in that more than one implementation can fill the broker role. The broker role being the primary distribution and subsequent aggregation of messages. Examples of brokers that are useful are:
- Debatching - Use a pipeline to debatch individual messages within an envelope and distribute to a dispatcher
- Multi-endpoint - Loop through a resolver collection distributing one message to multiple different dispatchers
- Sequential - A debatching broker that waits for a gather response before scattering the next message
Dispatch Correlator
The correlator is the glue between the broker and dispatcher. It does the following:
- Rewrap the dispatch correlation request payload in a dispatch request
- Write the following into the message context of the dispatch request: Thread ID, Dispatch Type and an IsInScatterGather boolean
- Relay the message to the message box after initialising a correlation set on the thread ID and dispatch type
- Relay the response received from the dispatcher, by following the correlation set, back to the broker
Abstract Dispatcher
Dispatchers are tightly coupled to an endpoint but loosely coupled to the broker. An implementation must always respond to the dispatch correlator to prevent orphaned processes. Examples of dispatchers that are useful:
- Itinerary - Uses the dispatch address to locate the itinerary to stamp to the message. An Itinerary Callback orchestration is paired with this dispatcher to callback into the dispatch correlator and must be configured as the final step in the itinerary that is spawned
- Loopback - Simply returns the message received. Used to allow the broker to relay the request in the aggregated response
Fault Manager
The fault manager subscribes to routed failed messages (FMR) and checks the message context for the IsInScatterGather boolean set by the dispatch correlator. If the context property is available and it's true then a dispatch correlation response is constructed to indicate a fault has occurred before being written to the message box.
Notes
There are a few important points to note about the model above:
- No delays are implemented in the framework to 'protect' it from orphaning threads
- Exception handling through the stack must be bullet-proof, period
- Contrary to typical ESB service development, strongly typed messaging between the components in the framework is key
No comments:
Post a Comment