This week, we’ll study a pattern known as Idempotent Receiver.
When do I use this pattern?
An Idempotent function is a function that returns itself when applied on itself. In messaging, an Idempotent Receiver will be able to process a duplicate message to result in the same end state of the system as if the message was processed once.
Idempotent Receiver in CPI
In CPI, I’ll demonstrate the Idempotent Receiver using an example of customer sync flow. The customer is updated in the master system and all the other systems should get the update.
The integration flow starts immediately using Timer Start Event, sets the body to be updated in Salesforce using Content Modifier, sends the request to Salesforce using AdvantCo’s Salesforce Adapter.
This payload is set in ‘Set Body’ content modifier:
<?xml version="1.0" encoding="UTF-8"?>
<Condition>Last_Modified_Date__c <= 2020-09-27T16:53:27.000Z</Condition>
In this example, the Idempotence is achieved using the message itself. The field Last_Modified_Date__c is set to a date and time when the customer was updated in the master system and the WHERE clause or the Condition field checks if the last modified date in the target system is in the past before actually performing the update.
If ECC is master and IDocs are being used to communicate change, then the fields CREDAT (created date) and CRETIM (created time) can be used to populate Last_Modified_Date__c. So, even if the same IDoc is sent twice because ECC did not receive an acknowledgement, the target system does not get updated unnecessarily.
EIPinCPI Rating – N/A
The EIPinCPI rating is not applicable for this pattern because the pattern describes how a receiver could be designed instead of the middleware system.
Idempotent Receiver is useful to prevent out of order or duplicate processing of the messages. In CPI, the Idempotence depends on the message itself and the receiver.
Hope this helps,
About the Author
More Content by Bhalchandra Wadekar