EIPinCPI – Selective Consumer

December 15, 2019 Bhalchandra Wadekar

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’.

Integration Flow


Exotic Liquids

The Integration flow starts immediately using Timer Start Event, reads the products only supplied by Exotic Liquids using OData Receiver Adapter, and logs the body using Groovy Script.

This is how OData Receiver Adapter is configured to make this flow a Selective Consumer:

Tab Property Value
Connection Address https://services.odata.org/V2/Northwind/Northwind.svc
Connection CSRF Protected Unchecked
Processing Operation Details Query (GET)
Processing Resource Path Products
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.


Products supplied by Exotic Liquids

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.

References/Further Readings

Hope this helps,

About the Author

Bhalchandra Wadekar

Bhalchandra Wadekar is an Integration Enthusiast who authored the Enterprise Integration Patterns in SAP Cloud Platform Integration (#EIPinCPI) series on SAP Blog Community. He is a fan of integration from API Management and Open Connectors to Message Based Integration and Data Integration.

More Content by Bhalchandra Wadekar
Previous Article
EIPinCPI – Message Dispatcher
EIPinCPI – Message Dispatcher

Next Article
EIPinCPI – Durable Subscriber
EIPinCPI – Durable Subscriber