Using Scatter-Gather

Mule 4 Indepth Using Scatter-Gather
13 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.39
List Price:  €93.41
You save:  €28.02
£55.92
List Price:  £79.90
You save:  £23.97
CA$96.01
List Price:  CA$137.16
You save:  CA$41.15
A$107.15
List Price:  A$153.08
You save:  A$45.93
S$95.13
List Price:  S$135.90
You save:  S$40.77
HK$547.14
List Price:  HK$781.66
You save:  HK$234.52
CHF 63.86
List Price:  CHF 91.23
You save:  CHF 27.37
NOK kr775.40
List Price:  NOK kr1,107.76
You save:  NOK kr332.36
DKK kr487.78
List Price:  DKK kr696.86
You save:  DKK kr209.07
NZ$118.01
List Price:  NZ$168.60
You save:  NZ$50.58
د.إ257.06
List Price:  د.إ367.24
You save:  د.إ110.18
৳7,680.49
List Price:  ৳10,972.60
You save:  ৳3,292.11
₹5,842.03
List Price:  ₹8,346.11
You save:  ₹2,504.08
RM332.86
List Price:  RM475.54
You save:  RM142.67
₦86,437.65
List Price:  ₦123,487.65
You save:  ₦37,050
₨19,491.96
List Price:  ₨27,846.85
You save:  ₨8,354.89
฿2,586.09
List Price:  ฿3,694.58
You save:  ฿1,108.48
₺2,265.39
List Price:  ₺3,236.41
You save:  ₺971.02
B$363.53
List Price:  B$519.35
You save:  B$155.82
R1,302.64
List Price:  R1,861
You save:  R558.35
Лв127.90
List Price:  Лв182.73
You save:  Лв54.82
₩96,270.48
List Price:  ₩137,535.16
You save:  ₩41,264.67
₪262.29
List Price:  ₪374.71
You save:  ₪112.42
₱4,033.94
List Price:  ₱5,763.02
You save:  ₱1,729.07
¥10,867.12
List Price:  ¥15,525.12
You save:  ¥4,658
MX$1,187.12
List Price:  MX$1,695.96
You save:  MX$508.84
QR254.93
List Price:  QR364.20
You save:  QR109.27
P994.08
List Price:  P1,420.18
You save:  P426.09
KSh9,360.69
List Price:  KSh13,372.99
You save:  KSh4,012.30
E£3,358.63
List Price:  E£4,798.26
You save:  E£1,439.62
ብር4,003.77
List Price:  ብር5,719.92
You save:  ብር1,716.15
Kz58,546.63
List Price:  Kz83,641.63
You save:  Kz25,095
CLP$67,216.99
List Price:  CLP$96,028.39
You save:  CLP$28,811.40
CN¥506.70
List Price:  CN¥723.89
You save:  CN¥217.19
RD$4,073.53
List Price:  RD$5,819.58
You save:  RD$1,746.04
DA9,418.34
List Price:  DA13,455.35
You save:  DA4,037.01
FJ$158.31
List Price:  FJ$226.17
You save:  FJ$67.86
Q543.96
List Price:  Q777.12
You save:  Q233.16
GY$14,650.29
List Price:  GY$20,929.88
You save:  GY$6,279.59
ISK kr9,815.39
List Price:  ISK kr14,022.59
You save:  ISK kr4,207.20
DH707.71
List Price:  DH1,011.06
You save:  DH303.35
L1,237.78
List Price:  L1,768.33
You save:  L530.55
ден4,025.24
List Price:  ден5,750.59
You save:  ден1,725.35
MOP$563.96
List Price:  MOP$805.69
You save:  MOP$241.73
N$1,304.33
List Price:  N$1,863.42
You save:  N$559.08
C$2,570.38
List Price:  C$3,672.13
You save:  C$1,101.75
रु9,397.27
List Price:  रु13,425.24
You save:  रु4,027.97
S/263.43
List Price:  S/376.35
You save:  S/112.91
K270.11
List Price:  K385.89
You save:  K115.77
SAR262.49
List Price:  SAR375.01
You save:  SAR112.51
ZK1,873.89
List Price:  ZK2,677.10
You save:  ZK803.21
L325.37
List Price:  L464.84
You save:  L139.46
Kč1,643.47
List Price:  Kč2,347.91
You save:  Kč704.44
Ft25,458.03
List Price:  Ft36,370.18
You save:  Ft10,912.14
SEK kr764.90
List Price:  SEK kr1,092.76
You save:  SEK kr327.86
ARS$61,327.27
List Price:  ARS$87,614.14
You save:  ARS$26,286.87
Bs483.57
List Price:  Bs690.85
You save:  Bs207.27
COP$273,218.78
List Price:  COP$390,329.27
You save:  COP$117,110.49
₡35,710.66
List Price:  ₡51,017.42
You save:  ₡15,306.75
L1,733.65
List Price:  L2,476.75
You save:  L743.09
₲524,442.73
List Price:  ₲749,236.02
You save:  ₲224,793.28
$U2,683.09
List Price:  $U3,833.15
You save:  $U1,150.06
zł283.24
List Price:  zł404.64
You save:  zł121.40
Already have an account? Log In

Transcript

Welcome back. In this video, we'll understand about what is scatter gather component. Before that, let me tell you my use case. Actually, I am working on this project, scatter gather start, where you have three flows. First flow, you can see that this is a flow, she's making REST API call. Sure correctly.

Yep, the first flow, you can see this is making a REST API call to get all the products GET request to slash products. So this will give me Jason of all the products. Now this transform method is converting that to Java. So I'll be getting list of products in Java format. So again, the second flow you can see it's making a soap request called Get out products. And the Transformers just converting the XML to list of products again in Java and this DB flow is firing a query Select star from products again, this transformer this converting to chow cycler three flows, each flow output will be a list of products.

Now what I want is I want another flow to make concurrent requests to all this flow by spinning up three threads wait until all three threads complete. Then gather the responses of all the three flows and then give it so that's where we can use scatter gather. Let us see First of all, I will drag and drop one more flow with a stipulation of Okay. I'll configure it with path slash all. Okay, then from my core module, I can drag and drop, scatter gather component. Okay.

Then I want to call three first concurrently, so I'll drag three flow references after scatter gather. Three flow references means actually where conflict three routes to scatter gather. Okay, we had to be very careful at drag and drop. Once the line comes at Yep, it is again and then drag and drop Presley. Yes. So the first floor reference I'll make it a point to say the flow.

I'll rename the flow also as the same name. Okay. Then second flow I'll map it to rest flow, the same name. Third flow reference, I'll map it to sub flow and the same display name. Okay? So I can't forget scatter gather three routes with three four references.

The output after scatter gather will be a list this Stop say three from three flows. Actually what scatter gather will do is since there are three routes, it has been of three threads and each thread will execute the floor reference. Concurrently the scatter gather will wait till all threats join, gather the response and give it back. So, after scatter gather the payload will be list of phase three in this case. So, now what I want is I want to transform the data using transform method so, drag and drop here, if you see the payload the rest of the the input for this transform message does the payload is of size three, right. payload is an object which contains identity objects Each object serving c payload is an array.

And here payload is anything you saying, Here payloads array, sexually, I want to get this nested payloads. Each payload is actually a list item in there. So I want to flatten and get one single list. Right first plus giving a list second first giving a list third, first giving a list. I want to flatten. So there's a simple function dw will call us flatten, flatten and you payload.

But where does the law is not alleged flatten accepts less. So I want all the necessary pillars dot dot payload. So dot dot means we'll get all the nested elements with name. So let's get into the list. That's how now I want The transformer to convert back to JSON so that I can display it on the browser. Yep, I made it.

Oh, let me run this. Okay, it's traffic. So, I try to request a local machine browser. So you request to localhost 8081 slash All right. I should get a list of all the objects from all the floors I got 12 that I got out. So if you see here in my console, everything is locked.

Right. And you can see the thread and there are three threads which chart which actually concurrently executed to get the result and scatter gathers. We waited until all three threads completed and it gathered. Okay, so what will happen if one of the one of the flow throws an exception? Let us see. What I'll do is I want my soap web service call to fail.

So I'll go and stop the server that is running. So that the flow will fail. Let us see what happened. The flow phase is very important for certification. ship and give. Refresh.

Yeah, I got an error. is it so important? Remember, if one of the route of scatter gather phase, scatter gather, also throw an exception. Please remember this, right? Now, if I double click on scatter gather, the total scatter gather was one of three threats in this case, and we will wait for all three that's joining. I want to configure timeout for reading, I can configure the timeout.

If I don't configure it will wait until the response comes. And maximum concurrency how many maximum threats can be pinned off concurrently? I can do here if I want. So these are the configurations ready to scatter gather. It's actually very scatter gather in core module. Yeah, here it is.

Right. Bye. Yeah there are some are some more some more also, there's one more thing for us first successful part of this fast successful let us try to understand the drag and drop workflow here yep first successful also can take multiple routes. So, I can drop flow references Yeah. So fast successful also can is taking multiple routes just like scatter gather, but what happens is whenever a request comes to first successful it invoke the first flow first round. If that is giving if that is not giving any exception, then the next flows next routes will not even executed.

Because the first route was successful. It was not throwing anything exception, but if first floor reference the first route throwing an exception, then the second flow second route will be executed. If this user, if this piece responds properly, third route will not be executed. So like that the first successful router will route and make sure that the first route fails, then secondary to the second route also fails. Third route is execute. So the first successful route responses given So, there are some there might be some use cases where you want failover.

So, let's assume that you have two soap endpoints for the same service maybe to serve web services, two endpoints that means two machines on which same soap web services running. You want the first for reference to always point to One of the you are if that fails then you want second as fallback if that also fails third of the fallback. In such cases we can use first successful. Okay. Now we want to support first successful surely one more interesting thing. There is one more thing also here in core until successful until successful also is something like us cope with drag and drop until successful actually is until successful what I can do is I can write any logic right now let's say drag and drop for reference.

Okay, and 40s until successful I can specify SR max Number of retries by default is five and milliseconds with 460,000 milliseconds. That means what whenever request comes to this until successful score, gateway aka for reference, if that is throwing an exception, then until successful, we'll wait for 60,000 milliseconds. And again, retry. Again retry invoking the for reference. Again, it fails. Again, wait for 60,000 milliseconds, again to try until the maximum number of retries are exhausted.

So if you want to actually retry executing some logic for a fair number of times, and if you want to wait before retrying, then you can use this until successful cope. Right. So that's some About how to use scatter gather until successful and also first unsexy first successful Excel See you next video. There is a lab which you can do for this scatter gather. Just go through this document and complete scatter gather document. I'll see you next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.