EIPinCPI – Selective Consumer
This week, we’ll study a pattern known as Selective Consumer.
When do I use this pattern?
Selective Consumer, as the name suggests, is used when the selection criteria for consuming a message is coded inside a consumer. The consumer decides whether the message is consumed or not. Note that Selective Consumer is different from Message Filter. In Message Filter, the consumer consumes the message and then decides to discard the message based on a condition. Whereas, Selective Consumer does not consume the message in the first place.
Selective Consumer in CPI
In CPI, I’ll demonstrate Selective Consumer using OData Receiver Adapter. We’ll use the same example from the Message Filter blog. The flow is interested only in products supplied by ‘Exotic Liquids’.
This is how OData Receiver Adapter is configured to make this flow a Selective Consumer:
|Processing||Operation Details||Query (GET)|
|Processing||Query Options||$filter=SupplierID eq 1|
Here, we are using OData Filter to implement a Selective Consumer.
When the integration flow is deployed, all products supplied by ‘Exotic Liquids’ are fetched and logged.
EIPinCPI Rating – 8/10
Selective Consumer in CPI is implemented easily using the configuration of Adapter. However, the implementation highly depends on the Adapter’s functionality. Therefore, I am going to rate Selective Consumer in CPI to be 8/10.
How can SAP improve EIPinCPI Rating?
JMS is one of the important features of CPI to support asynchronous messaging and retry mechanism. EIPinCPI rating would improve if JMS Sender Adapter supported Selective Consumer pattern. JMS Sender Adapter could have an input for selecting the message based on Header value or Exchange Property value.
Selective Consumer is useful when the consumer wants to consume message based on a condition. The alternative to using Selective Consumers is Message Dispatcher.
- Selective Consumer Pattern in Enterprise Integration Patterns
- CPI Components
Hope this helps,