1

I need to capture current flow name into a variable.

I tried with #[flow.name] but no luck in mule 3.8.0

can anybody please assist me?

Thiru
  • 404
  • 1
  • 16
  • 44

5 Answers5

3

Based on the answer in this post: How to get caller flow name in private flow in Mule

There is a simplest way to get the flow name and put it into a variable:

<expression-component doc:name="Expression"><![CDATA[flowVars.flowName = flow.name;]]></expression-component>
Community
  • 1
  • 1
sulthony h
  • 1,279
  • 1
  • 8
  • 9
  • 1
    @Thiru though it's a quite old thread but alternately, you can directly use expression `#[mule:context.serviceName]` in a variable to set the current flow name.. see the answer below – Anirban Sen Chowdhary Mar 20 '17 at 17:46
  • flow.Name won't work, if you execute it in a global MEL function that is being called from DataWeave. (Mule ESB 3.9.1) – Attila Sep 26 '18 at 06:10
3

Alternately, you can directly use expression #[mule:context.serviceName] in a variable :-

<set-variable variableName="myFlowName" value="#[mule:context.serviceName]" doc:name="Variable"/>
<!-- Print the value of variale in logger -->
<logger message="#[flowVars.myFlowName]" level="INFO" doc:name="Logger"/>

This will set your current flow name directly in variable

Anirban Sen Chowdhary
  • 8,233
  • 6
  • 39
  • 81
1

In mule 3.8.5 using Groovy script component,

flowVars.currentFlowName = eventContext.getFlowConstruct().getName();
RuntimeException
  • 1,593
  • 2
  • 22
  • 31
0

I have been using #[flow.name] in 3.7.3 and just tried in 3.8.0 to make sure it had not been removed and it worked fine for me in logger and setting a flowVars value. I suggest posting up at least a snippet of your flow and maybe we can spot the issue you are having.

PS, not sure why flow.name is not in standard forms or really documented by Mule, and as it is not there continues to be some worries they will remove it. I have seen it stated more than just here that it is not accessible in MEL, but #[flow.name] is a MEL expression and does work. To use if for something like I Parse Template in exception strategies, I use sulthony's form, set a flowVars value in an expression and refer to that flowVars in my template.

dlb
  • 357
  • 3
  • 13
-1

You can access flow name in logger by using #[flow.name] but its not accessible in MEL. Use flowconstruct for getting flow name. Refer this answer

Hope this helps.

Community
  • 1
  • 1
AnupamBhusari
  • 2,395
  • 2
  • 14
  • 22