Reputation: 6452
Consider the following case: I have a webservice that starts importing stuff from a source. I'd like to return 200 OK to the caller as soon as the call is accepted. There few different flows that need to executed in the right order.
<flow name="startImport" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
<async>
<flow-ref name="Country" />
<flow-ref name="Account" />
<flow-ref name="Contact" />
</async>
</flow>
Well, this doesn't work, as all of the flows are executed at once.
How about wrapping it in an another flow like this?
<flow name="startImport" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
<async>
<flow-ref name="startImport2" />
</async>
</flow>
<flow name="startImport2" processingStrategy="synchronous" >
<processor-chain>
<flow-ref name="Country" />
<flow-ref name="Account" />
<flow-ref name="Contact" />
</processor-chain>
</flow>
Nope, still the same result!
How can I stop the async-block making all the other flow-refs from turning async as well? I only want the first call to start asynchronously!
Upvotes: 2
Views: 424
Reputation: 11606
Private flows invoked via flow-ref
will pick up the synchronicity of the in-flight event.
To change this you can change the processingStrategy
of the flows you want to execute synchronously. Example:
<flow name="Country" processingStrategy="synchronous">
</flow>
Upvotes: 3
Reputation: 6452
Well, I ended up removing the flow refs and using vm-endpoints instead, like this:
<flow name="startImport" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
<async>
<vm:outbound-endpoint exchange-pattern="one-way" doc:name="VM" path="import-all.service.in"/>
</async>
</flow>
<flow name="startImport2" processingStrategy="synchronous" >
<vm:outbound-endpoint exchange-pattern="one-way" doc:name="VM" path="import-all.service.in"/>
<flow-ref name="Country" />
<flow-ref name="Account" />
<flow-ref name="Contact" />
</flow>
Now it works like I'd expect it to work, it quickly returns from the call and lets the async flow do the heavy lifting.
Upvotes: 0