Search code examples
asynchronousmulebatch-processingsynchronousmule-flow

Mule - Batch Job sync or async


I have two batch jobs in differents flows. The first, do an Upsert in Salesforce and when it finish, it call to the second flow that has another batch job.

This image represents the flows:

enter image description here

But when I see the log on the console, sometimes the log of the second batch is mixed with the log of the first.

I get the feeling that the batch processes are asynchronous and the second batch is called even though the first batch is being processed.

Am I wrong? Should I pay attention to the order of the logs? If I wanted it to be totally synchronous, what would be the best way?


Solution

  • Mule Batch is asynchronous, it is like fire and forget. If you want to call the second batch after first batch is completed, then invoke the second batch at 'On Complete' phase of first batch as shown in below picture.

    enter image description here

    If you want to do some function before invoking the second batch, then you need to use request-reply scope to make batch component synchronous.

    enter image description here