1

I've a private flow which is shared by lot of public flows using flow-ref. I'm looking to get the caller flow name in private flow, using MEL, using Mule 3.3.0. Is that possible?

Charu Khurana
  • 4,511
  • 8
  • 47
  • 81

1 Answers1

6

Mule doesn't add any property to an event when it invokes a private flow via flow-ref so your options are:

  • Use <set-variable> to set a variable with the flow name before calling the private flow and read this variable with #[flowVars.yourVariableName].
  • Use the inbound endpoint of the calling flow as the way to tell who's calling. You can get either the inbound endpoint URL with #[message.inboundProperties.MULE_ENDPOINT] or its name with #[message.inboundProperties.MULE_ORIGINATING_ENDPOINT].
  • Create a custom MessageProcessor that implements FlowConstructAware: that way you'll get the flow name and will be able to automatically set it as an invocation variable on the MuleEvent's message. Use this with a custom-processor element in all your parent flows, before the flow-ref.
David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • David, this expression is throwing exception ``. Exception is: `1. unable to resolve token: unable to resolve variable 'flow' (org.mvel2.UnresolveablePropertyException) org.mvel2.integration.impl.BaseVariableResolverFactory:60 (null) 2. Execution of the expression "flow.name" failed. (org.mule.api.expression.ExpressionRuntimeException)`. But this works fine: `` – Charu Khurana May 14 '13 at 18:10
  • `#[flow.name]` is not valid: the `flow` variable is not an implicit top level variable in MEL - see: http://www.mulesoft.org/documentation/display/current/MEL+Cheat+Sheet Again, Mule doesn't bind any variable with the flow name, you have to set it yourself: ``. I have added a third option BTW :) – David Dossot May 14 '13 at 18:47
  • I agree that flow is not a top level variable but when this statement worked: , it made me try irrational stuff. Can you tell please why is #[flow.name] working with logger – Charu Khurana May 14 '13 at 19:17
  • 4
    Man, looking at the source code, it seems there **is** an undocumented MEL variable named `flow` but it's unclear when it gets bound and when not. Apparently in `logger` it is, but not in `set-variable`. Maybe you can try with an expression component: it may get bound so you could do: `flowVars.callerFlowName = flow.name` in the `expression-component`. – David Dossot May 14 '13 at 19:39