0
votes

I have common scenario but I am not able to figure out the solution in Mule 4 batch. In my flow I have a http listner which invokes the flow and then I am calling DB select and then using a batch to upsert data into salesforce.

by default batch will create stats in On-Complete phase and my requirement is to send exact stats as response but I am not able to access it outside of batch. Tried with vars, attributes and even tried VM publish (in this case response will not go back to listner)

Can someone please guide me on this? I'm attaching the flow design for reference.

flow design

Thanks.

2

2 Answers

2
votes

You can't. Batch works in the background, your flow will be long gone before your batch is done. My suggestion is you (1) Store the reporting data somewhere and (2) get to the data using another request/way.

Here's the documentation: https://docs.mulesoft.com/mule-runtime/4.2/batch-processing-concept

2
votes

You can store the payload in on-complete phase in an objectStore and can retrieve it later to build your report. The payload stored in the on-complete phase is a java object that has properties that you would need to build your report. (For e.g.loadedRecords, failedRecords etc)..