Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhalchandraswcg
Contributor

Previous – Message Dispatcher | Index | Next – Durable Subscriber


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.

Output


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.

Conclusion


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,
Bala

 Previous – Message Dispatcher | Index | Next – Durable Subscriber

1 Comment
Labels in this area