P1-S10|

Опубликовано: 18 Май 2026
на канале: Mulesoft
374
6

‪@hb_mulesoftTechworld‬

Session Content
=============
Flow, sub-flow, private-flow scope use-cases
=======================
Flows are by default defines scope run in synchronous mode when we call using Flow reference, the task we need to perform will be executed and the result is limited to it.


Use-case1:
1. From main flow call privateflow/subflow.
2. Deploy and test, we can observe thread executes all the message processors in sequence.
3. And the flows will be executed synchronously

Check the console logs.

Asynchronous
============
Asynchronous scope executes the thread separately/independently,
and the components defined within Asynchronous scope will run in synchronous mode

For example, we have a new supplier and we need to create the supplier and send the status via email to stakeholders.

{
"supplierNumber": "sup4",
"supplierName": "Human Brains Supplychain",
"isActive": "No",
"address": "Kadapa",
"state": "Andhra Pradesh"
}

Create a flow post supplier,
and subflow to create the supplier record
Add logger "Supplier created successfully"
set payload {"message": "Supplier created successfully"}

Do a test, and observe
Add logger, setpayload (last 2 message processors) in Async scope.

Do a test, and observe



Archieve below using foreach
======
We have supplier information with multiple sites.
and we need to check for each site debitLimit , is based on postalCode
if postalCode starts with 5 set limit to 100,000
else set to 80,000

And this information we need to overwrite in our input payload/record.


Input:
{
"supplierNumber": "sup4",
"supplierName": "Human Brains Supplychain",
"isActive": "No",
"address": "Kadapa",
"state": "Andhra Pradesh",
"sites": [
{
"siteId": "s-1",
"name": "Hyderabad-Mfg",
"line1": "Balanagar",
"state": "Telangana",
"postalCode": "500001"
},
{
"siteId": "s-2",
"name": "Kadapa-Inv",
"line1": "Kadapa main st",
"state": "Andhra Pradesh",
"postalCode": "516101"
},
{
"siteId": "s-8",
"name": "Mumbai-Mfg-Inv",
"line1": "Bandra-Worli sealink suburb",
"state": "Maharashtra",
"postalCode": "400050"
}
]
}

The final response from the service should be like the below::

{
"supplierNumber": "sup4",
"supplierName": "Human Brains Supplychain",
"isActive": "No",
"address": "Kadapa",
"state": "Andhra Pradesh",
"sites": [
{
"siteId": "s-1",
"name": "Hyderabad-Mfg",
"line1": "Balanagar",
"state": "Telangana",
"postalCode": "500001",
"debitLimit": 100000
},
{
"siteId": "s-2",
"name": "Kadapa-Inv",
"line1": "Kadapa main st",
"state": "Andhra Pradesh",
"postalCode": "516101",
"debitLimit": 100000
},
{
"siteId": "s-8",
"name": "Mumbai-Mfg-Inv",
"line1": "Bandra-Worli sealink suburb",
"state": "Maharashtra",
"postalCode": "400050",
"debitLimit": 80000
}
]
}