Calling a flow using Groovy Script in Mule 4Starting a mule flow programmatically using groovyGroovy Script in Mule flow not workingMule- Access spring property placeholder inside groovy componentMule HTTP listener query in Groovy?auto-starting Mule flowMule - Intercept all flowsmule customizing the logger with flowsMule - how to use enumeration in groovy scripts?How to stop/start the Mule flows in multiple applications using Groovy scriptingPassing property value to a groovy class (not a groovy script) in mule flow

Can my floppy disk still work without a shutter spring?

Why was this character made Grand Maester?

Can I tell a prospective employee that everyone in the team is leaving?

Where is Jon going?

Does French have the English "short i" vowel?

SFDX: where can set Field-level security and accessibility?

Why did other houses not demand this?

Why would a rational buyer offer to buy with no conditions precedent?

Find this cartoon

If a (distance) metric on a connected Riemannian manifold locally agrees with the Riemannian metric, is it equal to the induced metric?

Python program to take in two strings and print the larger string

Are there any German nonsense poems (Jabberwocky)?

What does kpsewhich stand for?

Can I install a back bike rack without attachment to the rear part of the frame?

Should there be an "a" before "ten years imprisonment"?

Is there any relationship between frequency of signal and distance it travels?

Take elements from a list based on two criteria

How can I tell if I'm being too picky as a referee?

How to politely tell someone they did not hit "reply to all" in an email?

Why didn't Thanos use the Time Stone to stop the Avengers' plan?

Function argument returning void or non-void type

Must a warlock replace spells with new spells of exactly their Pact Magic spell slot level?

Gravitational effects of a single human body on the motion of planets

Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?



Calling a flow using Groovy Script in Mule 4


Starting a mule flow programmatically using groovyGroovy Script in Mule flow not workingMule- Access spring property placeholder inside groovy componentMule HTTP listener query in Groovy?auto-starting Mule flowMule - Intercept all flowsmule customizing the logger with flowsMule - how to use enumeration in groovy scripts?How to stop/start the Mule flows in multiple applications using Groovy scriptingPassing property value to a groovy class (not a groovy script) in mule flow






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I need to make a call to a flow using groovy script in mule 4. Can someone let me know if they have tried it using Mule 4










share|improve this question




























    0















    I need to make a call to a flow using groovy script in mule 4. Can someone let me know if they have tried it using Mule 4










    share|improve this question
























      0












      0








      0








      I need to make a call to a flow using groovy script in mule 4. Can someone let me know if they have tried it using Mule 4










      share|improve this question














      I need to make a call to a flow using groovy script in mule 4. Can someone let me know if they have tried it using Mule 4







      mule






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 1:16









      Piyush SinghPiyush Singh

      111




      111






















          1 Answer
          1






          active

          oldest

          votes


















          1














          It is possible, but I would HIGHLY recommend that you do NOT do it.



          You will have to dig deep down into the Mule Java APIs and couple yourself to them and also add a lot of your own error handling etc. and be wary of platform updates and the if the Java API changes.



          Personally I would restructure you app to only have 'business logic' in scripts and let Mule do the flow lookups elsewhere.



          You can even lookup flows in dataweave.



          But here is a rough working example(Note you will have to harden this code yourself):



          <flow name="test-flow">
          <scheduler>
          <scheduling-strategy>
          <fixed-frequency frequency="100000"></fixed-frequency>
          </scheduling-strategy>
          </scheduler>
          <set-payload value="bla bla" />
          <scripting:execute engine="groovy" doc:name="Toggle flow" doc:id="2eb6f071-bdef-4d3d-926d-2565fcd62d33">
          <scripting:code>
          import org.mule.runtime.api.message.Message;
          import org.mule.runtime.core.api.event.CoreEvent;
          import org.mule.runtime.core.api.event.EventContextFactory;
          flow=registry.lookupByName(&quot;another-flow&quot;).get();
          thisflow=registry.lookupByName(&quot;test-flow&quot;).get();
          msg = Message.builder().value(payload).build();
          event =CoreEvent.builder(EventContextFactory.create(thisflow,
          org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.fromSingleComponent("add-location"))).message(msg).build();
          result =flow.process(event);
          </scripting:code>
          </scripting:execute>
          </flow>

          <flow name="another-flow">
          <logger level="ERROR" message="Another Flow #[payload]" />
          </flow>


          You need to fetch the current flow and the flow you want to call.



          Using the Mule APIs - construct a Mule Event, Messgae, payload etc. You will also need to add any attributes you need etc.






          share|improve this answer

























          • Thanks Ryan for your response. I was able to achieve the functionality by using Java class instead of groovy.

            – Piyush Singh
            Mar 26 at 15:12











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319905%2fcalling-a-flow-using-groovy-script-in-mule-4%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          It is possible, but I would HIGHLY recommend that you do NOT do it.



          You will have to dig deep down into the Mule Java APIs and couple yourself to them and also add a lot of your own error handling etc. and be wary of platform updates and the if the Java API changes.



          Personally I would restructure you app to only have 'business logic' in scripts and let Mule do the flow lookups elsewhere.



          You can even lookup flows in dataweave.



          But here is a rough working example(Note you will have to harden this code yourself):



          <flow name="test-flow">
          <scheduler>
          <scheduling-strategy>
          <fixed-frequency frequency="100000"></fixed-frequency>
          </scheduling-strategy>
          </scheduler>
          <set-payload value="bla bla" />
          <scripting:execute engine="groovy" doc:name="Toggle flow" doc:id="2eb6f071-bdef-4d3d-926d-2565fcd62d33">
          <scripting:code>
          import org.mule.runtime.api.message.Message;
          import org.mule.runtime.core.api.event.CoreEvent;
          import org.mule.runtime.core.api.event.EventContextFactory;
          flow=registry.lookupByName(&quot;another-flow&quot;).get();
          thisflow=registry.lookupByName(&quot;test-flow&quot;).get();
          msg = Message.builder().value(payload).build();
          event =CoreEvent.builder(EventContextFactory.create(thisflow,
          org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.fromSingleComponent("add-location"))).message(msg).build();
          result =flow.process(event);
          </scripting:code>
          </scripting:execute>
          </flow>

          <flow name="another-flow">
          <logger level="ERROR" message="Another Flow #[payload]" />
          </flow>


          You need to fetch the current flow and the flow you want to call.



          Using the Mule APIs - construct a Mule Event, Messgae, payload etc. You will also need to add any attributes you need etc.






          share|improve this answer

























          • Thanks Ryan for your response. I was able to achieve the functionality by using Java class instead of groovy.

            – Piyush Singh
            Mar 26 at 15:12















          1














          It is possible, but I would HIGHLY recommend that you do NOT do it.



          You will have to dig deep down into the Mule Java APIs and couple yourself to them and also add a lot of your own error handling etc. and be wary of platform updates and the if the Java API changes.



          Personally I would restructure you app to only have 'business logic' in scripts and let Mule do the flow lookups elsewhere.



          You can even lookup flows in dataweave.



          But here is a rough working example(Note you will have to harden this code yourself):



          <flow name="test-flow">
          <scheduler>
          <scheduling-strategy>
          <fixed-frequency frequency="100000"></fixed-frequency>
          </scheduling-strategy>
          </scheduler>
          <set-payload value="bla bla" />
          <scripting:execute engine="groovy" doc:name="Toggle flow" doc:id="2eb6f071-bdef-4d3d-926d-2565fcd62d33">
          <scripting:code>
          import org.mule.runtime.api.message.Message;
          import org.mule.runtime.core.api.event.CoreEvent;
          import org.mule.runtime.core.api.event.EventContextFactory;
          flow=registry.lookupByName(&quot;another-flow&quot;).get();
          thisflow=registry.lookupByName(&quot;test-flow&quot;).get();
          msg = Message.builder().value(payload).build();
          event =CoreEvent.builder(EventContextFactory.create(thisflow,
          org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.fromSingleComponent("add-location"))).message(msg).build();
          result =flow.process(event);
          </scripting:code>
          </scripting:execute>
          </flow>

          <flow name="another-flow">
          <logger level="ERROR" message="Another Flow #[payload]" />
          </flow>


          You need to fetch the current flow and the flow you want to call.



          Using the Mule APIs - construct a Mule Event, Messgae, payload etc. You will also need to add any attributes you need etc.






          share|improve this answer

























          • Thanks Ryan for your response. I was able to achieve the functionality by using Java class instead of groovy.

            – Piyush Singh
            Mar 26 at 15:12













          1












          1








          1







          It is possible, but I would HIGHLY recommend that you do NOT do it.



          You will have to dig deep down into the Mule Java APIs and couple yourself to them and also add a lot of your own error handling etc. and be wary of platform updates and the if the Java API changes.



          Personally I would restructure you app to only have 'business logic' in scripts and let Mule do the flow lookups elsewhere.



          You can even lookup flows in dataweave.



          But here is a rough working example(Note you will have to harden this code yourself):



          <flow name="test-flow">
          <scheduler>
          <scheduling-strategy>
          <fixed-frequency frequency="100000"></fixed-frequency>
          </scheduling-strategy>
          </scheduler>
          <set-payload value="bla bla" />
          <scripting:execute engine="groovy" doc:name="Toggle flow" doc:id="2eb6f071-bdef-4d3d-926d-2565fcd62d33">
          <scripting:code>
          import org.mule.runtime.api.message.Message;
          import org.mule.runtime.core.api.event.CoreEvent;
          import org.mule.runtime.core.api.event.EventContextFactory;
          flow=registry.lookupByName(&quot;another-flow&quot;).get();
          thisflow=registry.lookupByName(&quot;test-flow&quot;).get();
          msg = Message.builder().value(payload).build();
          event =CoreEvent.builder(EventContextFactory.create(thisflow,
          org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.fromSingleComponent("add-location"))).message(msg).build();
          result =flow.process(event);
          </scripting:code>
          </scripting:execute>
          </flow>

          <flow name="another-flow">
          <logger level="ERROR" message="Another Flow #[payload]" />
          </flow>


          You need to fetch the current flow and the flow you want to call.



          Using the Mule APIs - construct a Mule Event, Messgae, payload etc. You will also need to add any attributes you need etc.






          share|improve this answer















          It is possible, but I would HIGHLY recommend that you do NOT do it.



          You will have to dig deep down into the Mule Java APIs and couple yourself to them and also add a lot of your own error handling etc. and be wary of platform updates and the if the Java API changes.



          Personally I would restructure you app to only have 'business logic' in scripts and let Mule do the flow lookups elsewhere.



          You can even lookup flows in dataweave.



          But here is a rough working example(Note you will have to harden this code yourself):



          <flow name="test-flow">
          <scheduler>
          <scheduling-strategy>
          <fixed-frequency frequency="100000"></fixed-frequency>
          </scheduling-strategy>
          </scheduler>
          <set-payload value="bla bla" />
          <scripting:execute engine="groovy" doc:name="Toggle flow" doc:id="2eb6f071-bdef-4d3d-926d-2565fcd62d33">
          <scripting:code>
          import org.mule.runtime.api.message.Message;
          import org.mule.runtime.core.api.event.CoreEvent;
          import org.mule.runtime.core.api.event.EventContextFactory;
          flow=registry.lookupByName(&quot;another-flow&quot;).get();
          thisflow=registry.lookupByName(&quot;test-flow&quot;).get();
          msg = Message.builder().value(payload).build();
          event =CoreEvent.builder(EventContextFactory.create(thisflow,
          org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.fromSingleComponent("add-location"))).message(msg).build();
          result =flow.process(event);
          </scripting:code>
          </scripting:execute>
          </flow>

          <flow name="another-flow">
          <logger level="ERROR" message="Another Flow #[payload]" />
          </flow>


          You need to fetch the current flow and the flow you want to call.



          Using the Mule APIs - construct a Mule Event, Messgae, payload etc. You will also need to add any attributes you need etc.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 25 at 21:48

























          answered Mar 25 at 16:11









          Ryan CarterRyan Carter

          9,96521523




          9,96521523












          • Thanks Ryan for your response. I was able to achieve the functionality by using Java class instead of groovy.

            – Piyush Singh
            Mar 26 at 15:12

















          • Thanks Ryan for your response. I was able to achieve the functionality by using Java class instead of groovy.

            – Piyush Singh
            Mar 26 at 15:12
















          Thanks Ryan for your response. I was able to achieve the functionality by using Java class instead of groovy.

          – Piyush Singh
          Mar 26 at 15:12





          Thanks Ryan for your response. I was able to achieve the functionality by using Java class instead of groovy.

          – Piyush Singh
          Mar 26 at 15:12



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55319905%2fcalling-a-flow-using-groovy-script-in-mule-4%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript