Scope of variables, attributes in Main flow and child flow in Mule 4

Let us see what is the scope of variables and attributes in Parent flow and Child Flow in Mule 4. To find out the exact scope I have created a flow with few loggers to clearly identify the scope. Few people often get confused about the scope of variables and attributes between parent flow and sub flow, private flow


What is the scope of variables and attributes between Mule application flows?


Scenario 1: Parent Flow calling child flow using HTTP Request component


I have created a flow which calls another flow using an HTTP Request component. Now the test is to find out the scope of the variable (created using Set variable) and URI Parameter (accessed using attributes expression)

Complete Guide and Tips to MuleSoft Certified Developer Certification

Flow:







Logs:


Scenario 2: Parent Flow calling child flow using Flow reference component


I have created a flow which calls another flow using a Flow reference component. Now the test is to find out the scope of variables (created using Set variable) and URI Parameter (accessed using attributes expression)

Flow:







Logs:



Complete logs analysis:

I have created a list of scope items that were tested from the above two scenarios. Scenario 1 calls the child flow with HTTP Request and scenario 2 calls the child flow with Flow reference component. The summary of the above test is the variables can be accessed throughout the flow. The attributes cannot be accessed beyond the external call in the same flow. The detailed representation can be viewed below.







Post a Comment

0 Comments