DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Error Handling Wikipedia in MuleSoft
  • MDC Logging With MuleSoft Runtime 4.4
  • MuleSoft Integration With RabbitMQ
  • Object Store Connector in Mulesoft

Trending

  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • Unlocking Data with Language: Real-World Applications of Text-to-SQL Interfaces
  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • Blue Skies Ahead: An AI Case Study on LLM Use for a Graph Theory Related Application
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. The Scope of Flow Variables and Session Variables in Async Flow in Mulesoft

The Scope of Flow Variables and Session Variables in Async Flow in Mulesoft

In this article, we will see how these variables are processed in an async scope of a flow.

By 
Radhika A user avatar
Radhika A
·
Jan. 16, 19 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
22.2K Views

Join the DZone community and get the full member experience.

Join For Free

Mule variables are used to store values for use in a flow or mule app. The values that can be stored in variables are objects, strings, numbers, messages, message attributes, message payloads, and dataweave expressions.

Mule 3 has 3 different types of variables:

  1. Flow variable

  2. Session variable

  3. Record variable

However, in Mule 4, the record variable is not there.

The scope of a flow variable is within a flow or subflow until there is no transport barrier like HTTP, VM, etc. Session variable scope is throughout the app even though there is a transport barrier.

In this article, we will see how these variables are processed in an async scope of a flow.

If you add an Async Flow in parent flow, the async flow runs in parallel along with the parent flow. The flow variable defined in the parent flow is passed to Async Flow and beyond it to the remaining flow. However, the changes in the variable inside the Async flow are not applicable or visible to the flow outside of the Async flow.

Async Flows don't send any response to parent flow. Let us see this in the example below:

Image title

In the example, the parent flow named AsyncExampleFlow calls the SubFlow named AsyncSubFlow using a flow reference component where the variable named number is set with value two.

From subflow (AsyncSubFlow) through VM connector, Flow2 is getting called since the flow variable crossed the transport barrier and the value of the number variable set in subflow is not applicable to Flow2.

The variable number is not accessible in the first logger in Flow2.

In Flow2, the number variable value is set as three. In the log, the value is printed as three from the second logger.

Once the subflow execution completes from parent flow, the async scope flow gets executed along with the parent flow. Even though inside the async flow the number variable value is set as four, the response we get through the payload is two. Since the value of the variable is set as two in the subflow, the same is returned to the parent flow.

The async scope does not return the response of flow variable to the parent flow as it is also executing along with the parent flow.

In the above example, instead of flow variable, if we use a session variable, the response will be three since the session variable scope is available outside of the transport barrier as well.

I hope you now understand flow variables in async flows a bit better. Please leave your feedback.

Flow (web browser) Session (web analytics) MuleSoft

Opinions expressed by DZone contributors are their own.

Related

  • Error Handling Wikipedia in MuleSoft
  • MDC Logging With MuleSoft Runtime 4.4
  • MuleSoft Integration With RabbitMQ
  • Object Store Connector in Mulesoft

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!