Reputation: 6334
I have a common set of steps that occur before and after an action. I would like to pass in a flow reference value to a common flow that takes these before and after actions.
is this possible in mule?
for clarity I want a flow that looks like this:
CommonStep1 --> CommonStep2 --> [InjectableFlowHere] --> CommonStep 3
I would then be able to pass this common flow a [InjectableFlowHere] component, whether it's a flowVariable or a property on the message, or something.
net-net I want to dependency inject a component into a flow.
update I would like InjectableFlowHere to be a flowRef where the flow name is
<flow-ref name="#[flowVars.Prefix]GetRequestFlow" doc:name="#[flowVars.Prefix]GetRequestFlow"/>
Upvotes: 1
Views: 1708
Reputation: 334
You can set flow-ref as MEL expression, like following:
<flow-ref name="#[flowVars.Prefix]-flow" doc:name="flow"/>
For instance:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.7.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<flow-ref name="flow-#[message.inboundProperties['http.query.string']]" doc:name="flow-1"/>
</flow>
<sub-flow name="flow-1">
<logger message="1" level="INFO" doc:name="Logger"/>
</sub-flow>
<sub-flow name="flow-2">
<logger message="2" level="INFO" doc:name="Logger"/>
</sub-flow>
</mule>
passing 1 or 2 as query string will route to respective sub-flow
Upvotes: 4