In several enterprise integration scenarios, a single message event will trigger a sequence of processing steps, with each one performing a specific process or action. For example, assume a new customer order arrives in our enterprise in the form of a message. To process this message, we may need to implement several requirements:
All messages will be encrypted
Ensure that orders are placed only by trusted customers, each message will contain authentication information in the form of a digital certificate
Eliminate duplicate messages before subsequent order processing steps are initiated.
To meet these requirements, we need to transform a stream of possibly duplicated, encrypted messages containing extra authentication data into a stream of unique, simple plain-text order messages without the extraneous data fields.
...
We can employ this integration pattern to sub-divide a larger complex process into a sequential series of smaller (and reusable) independent tasks or Filters. The sequence and flow of these filters is controlled by a set of channels (or Pipes).
Each of these filters follows a similar pattern of events: receives a message on the incoming pipe, processes the message, and then transmits the updated resulting message on the outgoing pipe. The pipe connects one filter to the next, sending output messages from one filter to the next.
Pipes and Filter using XML DSL:
Code Block | ||
---|---|---|
| ||
<route>
<from uri="activemq:order"/>
<to uri="bean:encrypt"/>
<to uri="bean:authenticate"/>
<to uri="bean:duplicates"/>
<to uri="activemq:invoice"/>
</route> |
Pipeline for the InOut Exchange Pattern
Normally, all of the endpoints in a pipeline have an input (In message) and an output (Out message), which implies that they are compatible with the InOut message exchange pattern. The pipeline connects the output of each endpoint to the input of the next endpoint. The Out message from the final endpoint is sent back to the original caller. You can define a route for this pipeline, as follows:
Code Block |
---|
<camelContext id="buildPipeline" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jms:RawOrders"/>
<to uri="cxf:bean:decrypt"/>
<to uri="cxf:bean:authenticate"/>
<to uri="cxf:bean:deDup"/>
<to uri="jms:CleanOrders"/>
</route>
</camelContext> |
NOTE: There is no dedicated pipeline element in XML DSL format, thus the preceding combination of from
and to
elements is semantically equivalent to a pipeline.
Pipeline for the InOnly and RobustOnly Exchange Patterns
When there are no Out messages available from the endpoints in the pipeline (ie. the case of the InOnly
and RobustInOnly
exchange patterns), our pipeline cannot be constructed in the normal way. In this case, the pipeline is built by passing a copy of the original In message to each of the endpoints in the pipeline.