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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Jakarta Faces Flow Scope: Managing Multi-Step UX Without Session State
  • Automating Power Automate: How to Ensure Cloud Flows Are Active After Every Pipeline Deployment
  • How Power Automate Helps Analysts Send Alert Emails Faster and How AI Builder Takes It to the Next Level
  • 2 Hidden Bottlenecks in Large-Scale Azure Migrations

Trending

  • RAG Is Not Enough: The Rise of Enterprise Knowledge Graphs for AI Systems
  • The Silent Container Death: A TCP Dial That Never Times Out
  • Agentic Test Creation: From Plain-Language Requirements to End-to-End Test Cases
  • Embabel vs LangGraph4j: Two Agentic Philosophies for Investment and Risk Analysis in BFSI

Mule: How to Stop or Start Flows in Mule 4.x Programmatically

Learn how to start or stop flows in Mule 4.x programmatically.

By 
Muralidhar Gumma user avatar
Muralidhar Gumma
·
Jul. 15, 19 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
16.8K Views

Join the DZone community and get the full member experience.

Join For Free

This article will describe the steps required to stop and start the flow in Mule 4 programmatically.

To be able to start and stop flows in Mule 4.x, you need to acquire the Mule Registry and then get the flow. This article provides a way to stop and start Mule flow using a Groovy script in Mule 4.x. 

You will need to perform the following steps:

1.      Add the scripting module to your project if you haven't previously added it

2.      Add a scripting component like the following:

<scripting:execute engine="groovy" doc:name="Toggle flow" doc:id="2eb6f071-bdef-4d3d-926d-2565fcd62d33" >
<scripting:code >flow = registry.lookupByName("flowName").get();
if (flow.isStarted())
flow.stop()
else 
flow.start()
</scripting:code>
</scripting:execute>

That Script will start the flow with name "flowName" if it is not started and stop it otherwise.

NOTE: Please replace "flowName" with the actual name of the flow you wish to start/stop or with a variable.

Flow (web browser)

Opinions expressed by DZone contributors are their own.

Related

  • Jakarta Faces Flow Scope: Managing Multi-Step UX Without Session State
  • Automating Power Automate: How to Ensure Cloud Flows Are Active After Every Pipeline Deployment
  • How Power Automate Helps Analysts Send Alert Emails Faster and How AI Builder Takes It to the Next Level
  • 2 Hidden Bottlenecks in Large-Scale Azure Migrations

Partner Resources

×

Comments

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

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook