Debatching in LogicApp


Hi friends,  In this article I would like to explain Debatching technique in Logic app with two examples.  Debatching is a technique of splitting your messages based on any repeated element in the message and process them separately.

1. Create a Logic app that receives Customer Records from SQL, those records we process them one by one inside a foreach loop. If one record takes 2 second of time, then 10 records will be processed in 20 seconds. Only one instances of Logic App will be created in this case.

2. Create 2 Logic apps, One is to receive the Customer records from SQL, Second is to split and process the records.


We receive Customer records from On-Premise SQL database by executing “GetCustomers” Stored Procedure, and post one by one into Salesforce (BTW, the ordering is not important). Before posting a new Customer, we should check if the Customer is already present in Salesforce.

Using Singleton Technique

Add “operationOptions”: “SincleInstance” in the code view that makes LA flow as Singleton(Single Instance will be created to process all requests)

here is the detailed description for the above Logic App. In this logic app,
1. Logic App get array of Customer Records like below from SQL

JSON Message

Using foreach loop we process one record at a time in this Logic App. This works alright but since there is no ordering we need to maintain, we could process them parallel. So we choose second option.

Using Debatching Technique

To use Debatching technique to split the record, we need 2 Logic Apps, One is to receive the Customer records from SQL, Second is to split and process the records.

Using this Logic App, every 3 mins. we poll a Stored Procedure named as “GetCustomers” and it returns list of customers. This Logic App posts the resultset of “GetCustomers”  in to another Logic App. The other Logic App looks like below,

Once we get the ResultSet, we check against empty validation, then we check if the Customer is already present in Salesforce, if not we create one, and send email confirmation.

To debatch the message, we need to use splitOn like below,


it is a code view of our Second Logic App, I have opened it in Chrome:\\apps->Json editor.


Now I am going to run this Second Sample which has used the Debatching technique. My On-Premise SQL data is below,

My first Logic App, which receives these records and post the same into Second Logic App.

2 instances of Second Logic App has been created.

Each instances of second Logic App would be as follows,


Using debatching technique in Logic App, we could increase the number of instance of Logic App to gain more CPU process to improve the flow. Also, if there are any failures after receiving the records from SQL, we could only retry each record of Second Logic App instances separately. By default, while processing Salesforce records, splitOn(“splitOn”: “@triggerBody()?.value”) is enabled. If you would like to maintain any ordering that you receive it from Salesforce just remove the SplitOn column from your Logic App flow.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Up ↑

%d bloggers like this: