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
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • 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
  • How to Create a Custom React Component in Vaadin Flow

Trending

  • Why Enterprise AI Agents Fail: A Runtime Data Governance Pattern for Reliable Answers
  • FastAPI + Django in Production: Lessons From a Hybrid Stack
  • Build Your Own Local AI QA Engineer With Docker, Ollama, LibreChat, and Playwright MCP
  • Calling GCP From AWS Without Static Keys Using Open-Source MultiCloudJ

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

  • 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
  • How to Create a Custom React Component in Vaadin Flow

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