---
schema_version: "1"
id: 74c495eeb9f1d3982a918b1bc2f1cf090bc20eb8359d0202e2161e68890c9b74
title: Round Robin Router
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/latest/round-robin.md
canonical_url: https://docs.mulesoft.com/mule-runtime/latest/round-robin
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 23c1cac049a09d3b5105790a620813139ad76b442d39c23b6e94a45a3bb37490
description: MuleSoft Documentation Site
release: "4.13"
latest: true
---
---
product: Mule Runtime
version: 4.13
is-latest-version: true
keywords: routers, flows, processor chain, async, aggregator, resequencer
---

# Round Robin Router

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Round Robin is a Mule component that contains two or more processing routes and executes only _one_
of the routes each time the flow executes the component. Each route within Round Robin is a scope
that can contain one or more processors. Starting with the first route, Round Robin initiates
execution of processors within the route over a Mule event and sends the results to the next
processor in the flow. Round Robin keeps track of the previously selected route and never selects
the same route consecutively. For example, the first time Round Robin executes, the component
selects the first route. The next time, it selects the second route. If the previously selected
route is the last route, Round Robin executes the first route.

The payload, variables, and attributes from the Mule event that reaches Round Robin are accessible
for processing within the route. Any changes to the Mule event within a route propagate to the
processor after Round Robin.

The following examples illustrates the functionality of Round Robin:

```xml
<flow name="round-robin-ex" >
  <scheduler doc:name="Scheduler" > <!-- 1 -->
    <scheduling-strategy >
      <fixed-frequency frequency="10" timeUnit="SECONDS"/>
    </scheduling-strategy>
  </scheduler>
  <set-payload value="#[[1,2,3,4]]" doc:name="Set Payload" /> <!-- 2 -->
  <logger level="INFO" doc:name="Logger"
          category="PAYLOAD BEFORE ROUND ROBIN"
  	message="#[payload]"/>
  <round-robin doc:name="Round Robin" >
    <route > <!-- 3 -->
      <set-payload value="#[payload - 4]" doc:name="Set Payload" />
      <logger level="INFO" doc:name="Logger"
              message="#[%dw 2.0&#10;output application/json&#10;---&#10;{ 'r1' : payload}]"
	      category="ROUTE 1 PAYLOAD"/>
    </route>
    <route > <!-- 4 -->
      <set-payload value="#[payload + 5]" doc:name="Set Payload" />
        <logger level="INFO" doc:name="Logger"
                message="#[%dw 2.0&#10;output application/json&#10;---&#10;{'r2' : payload}]"
                category="ROUTE 2 PAYLOAD"/>
    </route>
  </round-robin>
  <logger level="INFO" doc:name="Logger"
           message="#[payload]"
	   category="PAYLOAD OUTSIDE ROUND ROBIN"/> <!-- 5 -->
</flow>
```

1.  Scheduler (`<scheduler/>`) executes the flow every 10 seconds.

2.  Set Payload (`<set-payload/>`) provides the array `[1,2,3,4]`.

3.  The Logger component _before_ Round Robin prints the initial payload, `[1,2,3,4]`.

4.  In the _first_ route (`<route/>`) of Round Robin, a Set Payload component uses the DataWeave
    expression `payload - 4` to remove the last element of the initial payload, and the Logger in
    that route prints the resulting payload as the value of key `"r1"`, `{ "r1": [1,2,3] }`.

5.  In the _second_ route (`<route/>`) of Round Robin, a Set Payload component uses the DataWeave
    expression `payload + 5` to append a new element to the initial payload, and the Logger in that
    route prints the resulting payload as the value of key `"r2"`, `{ "r2": [1,2,3,4,5] }`.

6.  The Logger component _after_ Round Robin prints the payload of the route processed by an
    execution of Round Robin. The first execution prints `[1, 2, 3]`. The next execution prints
    `[1, 2, 3, 4, 5]`. The next prints `[1, 2, 3]`, and so on.

In the following excerpt, the logs show three executions of the Round Robin router. In this example,
the flow processes Mule events with IDs that begin `4df56260`, `53eb1c50`, and `59e12460`. (The
example is edited for readability.)

...

INFO 2022-12-19 10:02:30,233 ...event: 4df56260-7fc7-11ed-957f-147ddaaf4f97\] PAYLOAD BEFORE ROUND
ROBIN: \[1, 2, 3, 4\] INFO 2022-12-19 10:02:30,290 ...event: 4df56260-7fc7-11ed-957f-147ddaaf4f97\]
ROUTE 1 PAYLOAD: { "r1": \[1,2,3\] } INFO 2022-12-19 10:02:30,291 ...event:
4df56260-7fc7-11ed-957f-147ddaaf4f97\] PAYLOAD OUTSIDE ROUND ROBIN: \[1, 2, 3\]

INFO 2022-12-19 10:02:40,154 ...event: 53eb1c50-7fc7-11ed-957f-147ddaaf4f97\] PAYLOAD BEFORE ROUND
ROBIN: \[1, 2, 3, 4\] INFO 2022-12-19 10:02:40,167 ...event: 53eb1c50-7fc7-11ed-957f-147ddaaf4f97\]
ROUTE 2 PAYLOAD: { "r2": \[1, 2, 3, 4, 5\] } INFO 2022-12-19 10:02:40,168 ...event:
53eb1c50-7fc7-11ed-957f-147ddaaf4f97\] PAYLOAD OUTSIDE ROUND ROBIN: \[1, 2, 3, 4, 5\]

INFO 2022-12-19 10:02:50,151 ...event: 59e12460-7fc7-11ed-957f-147ddaaf4f97\] PAYLOAD BEFORE ROUND
ROBIN: \[1, 2, 3, 4\] INFO 2022-12-19 10:02:50,154 ...event: 59e12460-7fc7-11ed-957f-147ddaaf4f97\]
ROUTE 1 PAYLOAD: { "r1": \[1, 2, 3\] } INFO 2022-12-19 10:02:50,154 ...event:
59e12460-7fc7-11ed-957f-147ddaaf4f97\] PAYLOAD OUTSIDE ROUND ROBIN: \[1, 2, 3\]

...

## Reference

Round Robin provides a configurable attribute to the `<round-robin />` element.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Name</th><th>XML</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p>Business Events</p></div></div></td><td><div><div><p><code>tracking:enable-default-events="true"</code></p></div></div></td><td><div><div><p>Defaults to <code>false</code>. Enables tracking of business events. See <a href="https://docs.mulesoft.com/mule-runtime/latest/business-events">Business Events</a>.</p></div></div></td></tr></tbody></table>

## Throws

- `MULE:ROUTING`
