user3675877
user3675877

Reputation: 43

Synchronization of different flows in mule

I have 2 flows, A.flow and B.flow, eventually both flows execute the same java class.

A & B read from a separate Queue.

I want to synchronize the flows so that if both flows get input simultaneously then one flow at a time process and after it finishes, the other flow will start processing.

Any ideas?

thanks

Upvotes: 1

Views: 937

Answers (1)

Ale Sequeira
Ale Sequeira

Reputation: 2039

Use a pooled component and configure it to use one thread at a time:

<flow name="A">
    <jms:inbound-endpoint...>
    ...
    <vm:outbound-endpoint path="process"/>
    ...
</flow>

<flow name="B">
    <jms:inbound-endpoint...>
    ...
    <vm:outbound-endpoint path="process"/>
    ...
</flow>

<flow name="process">
    <vm:inbound-endpoint path="process"/>
    <pooled-component class="org.my.PrototypeObject">
        <pooling-profile exhaustedAction="WHEN_EXHAUSTED_WAIT" initialisationPolicy="INITIALISE_ALL" maxActive="1" maxIdle="1" maxWait="1000" /> </pooled-component>
    </pooled-component>
</flow>

Source: http://www.mulesoft.org/documentation/display/current/Configuring+Java+Components#ConfiguringJavaComponents-ConfiguringaPooledJavaComponent

Upvotes: 2

Related Questions