Reputation: 6717
What is the difference between Subflow and Processor-Chain in Mule?
As far as I have used both are re-usable. Both makes the config more readable. Both execute synchronously. Both inherit the processing strategy and exception-strategy from the triggering flow.
Processor-chain can be defined inside the flow as well as a global message processor.
Apart from this how are they different in terms of behaviour and usage.
Update: Example config with Named Processor Chain
<flow name="man-flow" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="myapp/collection-processor" doc:name="HTTP">
<byte-array-to-string-transformer></byte-array-to-string-transformer>
</http:inbound-endpoint>
<expression-component doc:name="Expression"><![CDATA[java.util.ArrayList list = new java.util.ArrayList();
list.add("First String");
list.add("Second String");
list.add("Third String");
payload = list;]]>
</expression-component>
<request-reply>
<vm:outbound-endpoint path="split"/>
<vm:inbound-endpoint path="processed"/>
</request-reply>
<set-payload value="#[payload.toString()]"/>
</flow>
<processor-chain name="sample-processor-chain">
<append-string-transformer message=" in splitter" />
<append-string-transformer message=" in processor-chain" />
</processor-chain>
<flow name="splitter-flow">
<vm:inbound-endpoint path="split"/>
<collection-splitter enableCorrelation="IF_NOT_SET"/>
<processor ref="sample-processor-chain"></processor>
<vm:outbound-endpoint path="aggregate"/>
</flow>
<flow name="aggregator-flow">
<vm:inbound-endpoint path="aggregate"/>
<collection-aggregator timeout="30000"/>
<vm:outbound-endpoint path="processed"/>
</flow>
Upvotes: 3
Views: 7628
Reputation: 2039
processor-chain
was created to address the problem of some message processors not allowing more than one nested processor.
The idea behind sub-flow
is a macro expansion of a series of message processors. If you use the latests Mule versions you shouldn't use processor-chain very much, except for some really old constructions. Using sub-flows allows you to have a much more readable code, for example, to include repetitive stuff.
Upvotes: 4