This week, we’ll study a routing pattern known as Composed Message Processor.
When do I use this pattern?
When a series of related steps form a single unit of work, Composed Message Processor pattern can be applied. For example, consider an order with multiple order items. Each item may require separate steps to complete order processing. Finally, the order items need to be combined back into the originating order. And, this order will be sent to the reporting tool.
These steps can be achieved using patterns we studied before. To process order items individually, Splitter pattern can be applied. Combining the order items back into the order can be achieved using the Aggregator pattern. These two steps can be thought of as a single step in a larger context of work. And a unit that performs this work can be called Composed Message Processor.
Composed Message Processor in CPI
Integration Flow – Composed Message Processor
This integration flows wraps all the steps required to process an order and exposes it using ProcessDirect Adapter. The individual steps are to split the order items so they can be sent to a Delivery System individually and then combine the order items back into an order using an Aggregator. In other words, this integration flow accepts an Order message and returns an Order message.
Integration Flow – Consumption
This integration flow consumes the Composed Message Processor. Here, the advantages of using a Composed Message Processor are seen. This flow can use processing an order as a single step and does not need to know details of processing an order. Also, it only needs to work on a single message before and after calling the Composed Message Processor step.
Composed Message Processor can be used to implement encapsulation in integration. Composed Message Processor can be implemented using a combination of an Integration Process and ProcessDirect Adapter in CPI.
- Composed Message Processor Pattern in Enterprise Integration Patterns
- CPI Components
Hope this helps,