Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mule processing strategies - call async private flow from synchronous flow

Tags:

mule

I am trying to call an async private flow from a main synchronous flow like so:

<flow name="main" doc:name="main" processingStrategy="synchronous">
    <poll frequency="10000">
        <set-payload value="main"></set-payload>
    </poll>

    <flow-ref name="async-private" />
    <flow-ref name="private" />

</flow>
<flow name="private" processingStrategy="synchronous">
    <logger level="ERROR" message="sync" />
</flow>

<flow name="async-private" processingStrategy="asynchronous">
    <logger level="ERROR" message="async" />
</flow>

But it does not work and results in the following exception:

Unable to process a synchronous event asynchronously. Message payload is of type: String (org.mule.api.MessagingException)

What is going on here?

UPDATE

It works if I wrap the async flow-ref in <async> tags. But why do I need to do this? Is it a bug?

like image 924
jon lee Avatar asked Jan 11 '23 03:01

jon lee


1 Answers

This is a feature.

You are in an explicit synchronous flow and try to call an explicit asynchronous one. The response from the asynchronous flow will never make it back to the caller flow. Thus there is a potential for losing messages. Thus Mule forces you to be explicit and wrap with <async> tags.

like image 154
David Dossot Avatar answered Apr 30 '23 15:04

David Dossot