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

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Explore Salesforce OAuth Authorization Flows and Its Use Cases
  • Build a Flow Collectibles Portal Using Cadence (Part 2)
  • Build a Digital Collectibles Portal Using Flow and Cadence (Part 1)
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)

Trending

  • Event Driven Architecture (EDA) - Optimizer or Complicator
  • Build a Simple REST API Using Python Flask and SQLite (With Tests)
  • Monolith: The Good, The Bad and The Ugly
  • How to Create a Successful API Ecosystem
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Async Scope With Mule ESB

Async Scope With Mule ESB

Using Mule's Async scope, you can process an activity in your flow without stopping the flow. This tutorial will show you how.

By 
Jitendra Bafna user avatar
Jitendra Bafna
DZone Core CORE ·
Jun. 01, 17 · Tutorial
Likes (10)
Comment
Save
Tweet
Share
21.2K Views

Join the DZone community and get the full member experience.

Join For Free

The Async scope is a branch processing block that executes simultaneously with the parent message flow. This means that you have an activity in the flow that can be processed without stopping the flow. There are some time-consuming operations (printing a file or sending SMTP email) which don’t have a dependency in further flows. In such scenarios, you can use the Async scope.

There are two flows, the parent and child flow, in your Mule application. The parent flow is calling the child flow to perform some task, but the parent flow doesn’t have a dependency from the result of the child flow. In such scenarios, if you don’t use the Async scope, the parent flow stops its execution until child flow completes its execution.

In such scenarios, we should use Async scope, so the parent and child flow will both execute in parallel, in different threads. The scope is basically known as a wrapper. Mule provides the Async scope and it is available in Mule palette.

Image title

Drag and drop the HTTP Listener in canvas and configure it.

Image title

Drag and drop the other flow (child flow) below the parent flow. Place the Groovy component and add a script for the flow to wait for 30 seconds.

Image title

Place a Set Payload component after Groovy in child flow.

Image title

Place the Async scope in the parent flow and then the flow reference component in the Async scope. Call the child flow.

Image title

Place the Set Payload component in the parent flow.

Image title

Once you POST the message, the parent flow will call the child flow asynchronously. The child flow will wait for 30 seconds but the parent flow will not stop its execution. It will continue its processing. Both the flows will continue the processing in parallel.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
    <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="async-scopeFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/async" allowedMethods="POST" doc:name="HTTP"/>
        <async doc:name="Async">
            <flow-ref name="async-scopeFlow1" doc:name="async-scopeFlow1"/>
        </async>
        <set-payload value="#['Parent Flow Completed']" doc:name="Set Payload"/>
    </flow>
    <flow name="async-scopeFlow1">
        <scripting:component doc:name="Groovy">
            <scripting:script engine="Groovy"><![CDATA[sleep(30000)]]></scripting:script>
        </scripting:component>
        <set-payload value="#['Child flow executed.']" doc:name="Set Payload"/>
    </flow>
</mule>

Here is the video tutorial:


Now you know about the Async scope with Mule ESB.

Enterprise service bus Flow (web browser)

Opinions expressed by DZone contributors are their own.

Related

  • Explore Salesforce OAuth Authorization Flows and Its Use Cases
  • Build a Flow Collectibles Portal Using Cadence (Part 2)
  • Build a Digital Collectibles Portal Using Flow and Cadence (Part 1)
  • A Better Web3 Experience: Account Abstraction From Flow (Part 1)

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!