Thiru
Thiru

Reputation: 424

How to find current flow name in mule?

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?

Upvotes: 1

Views: 4854

Answers (5)

RuntimeException
RuntimeException

Reputation: 1643

In mule 3.8.5 using Groovy script component,

flowVars.currentFlowName = eventContext.getFlowConstruct().getName();

Upvotes: 1

Anirban Sen Chowdhary
Anirban Sen Chowdhary

Reputation: 8311

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

Upvotes: 3

dlb
dlb

Reputation: 357

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.

Upvotes: 0

sulthony h
sulthony h

Reputation: 1277

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>

Upvotes: 3

AnupamBhusari
AnupamBhusari

Reputation: 2415

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.

Upvotes: -1

Related Questions