Batching (aggregating) messages using batch receive and batch sender in a Logic App
Below is a step-by-step guide to create an Azure Logic App workflow that uses Batch Receive and Batch Sender actions to process XML messages. The workflow will:
- Receive XML messages.
- Add a root tag to the batched XML messages.
- Send the final batched XML message via Gmail.
Step-by-Step Workflow
Step 1: Create the Batch Receiver Logic App
This Logic App will receive and process XML messages in batches.
- Go to the Azure portal and create a new Logic App.
- Add a Batch Trigger:
- Search for Batch and select When messages are received in a batch.
- Configure the batch settings:
- Release criteria: Message count base
- Message Count: 2
- Mode: Inline
- Add a Initialize variable set type: String and value: “</Employees>”.
- Add a For Each loop to iterate through the batch of messages.
- Inside the loop, add a Append to string variable action to process each XML message. For example:
- Value:
@item()['content']
- Value:
- Add a Append to string variable action outside the loop to add a end root tag to the batched XML messages. For example:
- Value: </Employees>
- Add a Gmail action to send the final batched XML message:
- To: Enter the recipient’s email address.
- Subject:
Batched Final Message - Body: Here is the result of the batched message
@{variables('rootName-Var')}
Step 2: Create the Batch Sender Logic App
This Logic App will send XML messages to the Batch Receiver.
- Create another Logic App.
- Add a trigger When a HTTP request is received.
- Add a Batch Sender action:
- Search for Batch and select Send messages to batch.
- Configure the batch settings:
- Batch Receiver: Select the Logic App created in Step 1.
- Message Content:
@triggerBody()
Here's how Logic Apps should look:
Batch Receiver Logic App

Batch Sender Logic App

Testing the Workflow
- The Batch Sender will send the XML messages to the Batch Receiver.
- The Batch Receiver will process the messages based on condition (e.g. message count = 2).
- The Batch Receiver will add a root tag to the batched XML messages.
- The Batch Receiver will send the final batched XML message via Gmail.
Sample Input
Batch Sender sends 2 XML messages:
<message> <id>1</id> <name>John Doe</name> </message>
<message> <id>2</id> <name>Jane Smith</name> </message>
Sample Output
The Batch Receiver will process the messages and add a root tag:
<Employees> <message> <id>1</id> <name>John Doe</name> </message> <message> <id>2</id> <name>Jane Smith</name> </message> </Employees>
You can download the logic app template from the estudy247 GitHub repository – Batch Receiver: la-test-batch-15 and Batch Sender: la-test-batch-16
