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
1,721

Previous – Transactional Client | Index | Next – Event-driven Consumer


This week, we'll study a pattern known as Polling Consumer.

When do I use this pattern?


Polling Consumer is one of the most popular scenarios. A Polling Consumer is used when the consumer wants to control the time at which it wants to receive the message. A Polling Consumer may process all the messages at once at midnight to reduce the processing during daylight. A Polling Consumer may receive the next set of messages when the resources are available to process the next set of messages.

The most common example of polling consumer in middleware is the use of SFTP Sender Adapter. Files are polled in a given directory at the scheduled time.

In CPI, a polling consumer can be created for any adapter by use of Timer Start Event. Isn't that cool!

Polling Consumer in CPI


SFTP Sender Adapter


The SFTP Sender Adapter in CPI enables connection to a remote system using SSH File Transfer Protocol. The adapter can be configured to fetch the files on a schedule. The Integration Flow that uses SFTP Sender Adapter gets the messages as per the schedule, thereby making the integration flow a Polling Consumer.

Integration Flow



SFTP


In this demonstration, I'll be fetching the files at midnight and simply logging the file contents.

This is the scheduler configuration of SFTP Sender Adapter:


SFTP Schedule


The integration flow would stay dormant until midnight. At midnight, it will fetch all the files in the configured directory and log them.

Timer Start Event


Timer Start Event enables the integration flow to start on schedule. Until now, in EIPinCPI blog series, we have used Timer Start Event to start the integration flow immediately. Now, we'll use the Timer Start Event to start the integration flow at midnight. The integration flow will fetch the customers using OData Receiver Adapter and log it.

Integration Flow



Timer Start Event


Similar to SFTP Polling Consumer above, this integration flow starts at midnight, fetches all the customers changes since yesterday and logs it.

As we can see here, the use of Timer Start Event enables any kind of scenario to be configured as a Polling Consumer.

Many other adapters have built-in features to use the Polling Consumer pattern including these:

Do you know any other adapters that support Polling Consumer pattern? Put them in the comments and I'll add them in this list.

Conclusion


Polling Consumer is used when the consumer needs to control when it wants to receive the messages. The control is exercised using a schedule in most scenarios. However, resource-based control is also possible.

References/Further Readings



Hope this helps,
Bala

Previous – Transactional Client | Index | Next – Event-driven Consumer

Labels in this area