Skip to Content
Technical Articles

EIPinCPI – Idempotent Receiver

Previous – Durable Subscriber | Index | Next – Service Activator

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.

Integration Flow

Customer%20Sync

Customer Sync

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"?>
<UpdateMultipleObjectsOperationsSchema>
    <Account>
        <Operation>UPDATE</Operation>
        <ObjectType>Account</ObjectType>
        <ExternalID>SAP_Customer_Id__c</ExternalID>
        <Condition>Last_Modified_Date__c &lt;= 2020-09-27T16:53:27.000Z</Condition>
        <TransactionLevel>REQUIRED</TransactionLevel>
        <sObjects>
            <sObject>
                <SAP_Customer_Id__c>0051234567</SAP_Customer_Id__c>
                <Name>SAP</Name>
                <Last_Modified_Date__c>2020-09-27T16:53:27.000Z</Last_Modified_Date__c>
            </sObject>
        </sObjects>
    </Account>
</UpdateMultipleObjectsOperationsSchema>

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.

Conclusion

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.

References/Further Readings

Hope this helps,
Bala

Previous – Durable Subscriber | Index | Next – Service Activator

/
Customer%20Sync
Be the first to leave a comment
You must be Logged on to comment or reply to a post.