Round Robin In Mule 4

DZone 's Guide to

Round Robin In Mule 4

In this article, take a look at round robin in Mule 4.

· Integration Zone ·
Free Resource

What Is Round Robin?

In the round-robin arrangement, we will choose all the elements with equal rational order i.e with the same difference between any two elements in a group.

If we consider a real-time scenario of a computer operation, different processes of a program using the same method will often process for a specific time period and then leaves the thread of that process to be used by another process of that method.

Real-World Example:

Round Robin in MuleSoft:

The Round Robin switch repeats through a rundown of at least two routes altogether, yet it just routes to one of the routes each time it is executed. It monitors the recently chosen route and never chooses a similar route successively. For instance, the first run through Round Robin executes, it chooses the primary route. Whenever it chooses the subsequent route. On the off chance that the recently chosen route is the last route in the rundown, Round Robin bounces to the primary route.

How to get Round Robin in Mule 4:

Step 1:

In Anypoint Studio, click the Search tab in the pallet and type the module name (round robin).

Step 2:

Click the module and drag it into the canvas.

Example for Round Robin in Mule 4

Using the scheduler component to develop a round-robin process based on cron expression.

Please follow the below steps:

Step 1:

Create a New Mule Project as Shown Namely as Round_Robin.

Step 2:

Drag and drop a Scheduler component to get a request for your servers.

Step 3:

In that scheduler, we can choose any of the Scheduling Strategy's i.e

1. Fixed Frequency





The frequency at which the Scheduler triggers the flow


Start Delay

The amount of time to wait before triggering the flow for the first time after the application is started


Time Unit

The time unit for the values of Frequency and Start Delay


2. Cron

Cron is a broadly utilized standard for depicting time and date information. The Scheduler monitors each second and makes a Mule occasion when the Quartz Cron articulation coordinates your time-date setting. You can trigger the occasion only a single time or at ordinary interims.

A date-time articulation comprises of six required settings and can incorporate the discretionary year setting. You indicate the settings in the accompanying request:

  • Seconds (0-59)
  • Minutes (0-59)
  • Hours (0-23)
  • Day of month (1-31)
  • Month (1-12 or JAN-DEC)
  • Day of the week (1-7 or SUN-SAT)
  • Year (empty or a 4-digit year between 1970-2099, for example, 2019)

Here are a few examples



1/2 * * * * ?

Run every 2 seconds of the day, every day

0 15 10 ? * *

Run at 10:15 a.m., every day. 0 15 10 * * ? * and 0 15 10 * * ? produce the same effect.


The Scheduler component also supports Quartz Scheduler's special characters.

  • *: All values
  • ?: No specific value
  • -: Range of values
  • ,: Additional values
  • /: Incremental values
  • L: Last day of the week or month, or last specific day of the month (such as 6L for the last Saturday of the month)
  • W: Weekday, which is valid in the month and day-of-the-week fields
  • #: Nth day of the month. For example, #3 is the third day of the month

As per example, I choose Cron Scheduling Strategy


As per Cron Expression (* * * * * ?), Every second it will be Restart the service

Step 4:

Now, drag and drop the Round Robin component from the Mule Palette on to the Designed Canvas.

Step 5: 

Next, take two loggers for checking the techniques of the round-robin.

Logger1 as Route-1

Logger2 as Route-2

Now, we look about the entire flow of the project as below

Step 6:

Run the Project




In the model over, the first run through the Round Robin is executed it prints Route-1. Whenever it prints Route-2. The third time, since there are just two routes, Round Robin begins again with the principal route and prints Route-1.

Thanks for reading!

integration ,mule 4 ,mulesoft ,round robin

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}