Posted on Leave a comment

Until Successful

UNTIL SUCCESSFUL

 

The Until Successful scope processes the components within it until they succeed or exhaust the maximum number of retries.

Until Successful runs synchronously.

Until Successful component

Configure of Until-Successful-

Max Retries:- Specifies the maximum number of retries that are attempted

Milliseconds Between Retries:- Specifies the minimum interval between   two attempts to process, in milliseconds, Default value is 1 Min

 

Step1:-

Wrap the HTTP Requester inside Until Successful

Step2:-

We have configured the Retries Interval as 20 ms (You can configure as per the requirement) and max Retries is 3.

 

Step3:-

In case of success scenario ,

there will not be any error received from Rest API(http status will be 200) and success response will be retrieved.

In case of failure scenario

Until Successful retries the failed task until all configured retries are exhausted and if final retry does not succeed . until successful produces an error.

if a retry succeeds .the scope proceeds to next component

Posted on Leave a comment

Round-Robin

Round Robin

This router iterates through all the routes in the router component in a specific order but it only routes to one of the routes each time it is executed. For example, it keeps track of the last route it selected for execution and will not execute the same route again consecutively.

Basically, this router works in a circular manner and whichever route executes first will not be executed in the next execution till all the other routes are executed at least once.

Round Robin component

Use Case :-

Below is the simple demo where the “first-logger” route will execute first and in the immediate next iteration,”second-logger” will be executed and this sequence will continue.

 

First-logger is executing

Second-logger is executing:-

 

 

Posted on Leave a comment

Scatter-Gather

Scatter-Gather

“Scatter-Gather sends the requested data to multiple routes concurrently“.

It waits for all the routes to complete the execution and then aggregates the response from each route and forms a Single output message and output will be “application/java” format.

 

 

Use Case :-

 

Response:-

You can see in console of studio,

In above picture, uber01 and uber02 both are threads. and “Scather-gatherapiFlow/processors/0/route/0/processors/0” is first route path and “Scather-gatherapiFlow/processors/0/route/1/processors/0” is second route path.

 

NotePoint1:-

“The maximum time taken by Scatter-Gather to complete the execution is the max time taken by any route. For instance, if route-1 takes 5 secs and route-2 takes 10 secs then Scatter-Gather will take 10 secs to complete the execution.”

NotePoint2:-

“one of the routes fails, then the entire Scatter-Gather process fails.”

 

Working-flow

 

1-first route will be trigger

2-Second flow will be trigger

In debug mode, We can see working of processor.

 

Posted on Leave a comment

Choice Router

Choice

Choice Router works on the evaluation of the expression i.e., True or False. The Route for which the expression evaluates to be True, that route is executed.

It executes routes sequentially i.e. if for both route-1 and route-2 condition expression evaluates to be true, it will execute only route-1 because of its sequential nature and will not execute route-2.

The expression cannot be kept as blank and there is a default block that executes if none of the expressions evaluates to True.

 

Use Case 1:-

in above picture,

we set the variable “Id” and  value is “payload.empId”.

We are sending empId in body section.

Response:-

 

Use Case 2:-

If “empId” is null , then this comes in the input then the Default route will be triggered.

We are sending Null empId in body.

Response:-

 

Posted on Leave a comment

Flow Control in Mule 4

We will see four different Flow control components provided in Mule. We will also cover various use cases.

In Mule, Flow Controls , you Route your input Mule Event into one or more  separate flows based on the Flow control components you use.

Type of Flow Control component:-

1-Choice

2-Scatter-Gather

3-Round-Robin

4-First Successful

 

The detailed explanation on each topics is in next section.