Reputation: 15
I am implementing a mule app that fetches data from a database and syncs it to different CRMs on a specific condition, e.g. if 10 records are fetched, 3 of them might be synced with Hubspot and 7 with Salesforce. I am using the integration APIS of all CRMS. I want to make a separate sub-flow for each CRM. But Mule doesn't allow me to drag and drop a batch job in a sub flow. Is it achievable? What other options are there for this implementation?
Upvotes: 0
Views: 424
Reputation: 3315
As of today, Batch job can only be inside a flow
and not a sub-flow
. You can however reference this flow from a flow-reference
from any other flow.
Now regarding your requirement of passing the records to different CRMs. I will not recommend creating multiple batch jobs for a single message. As instantiating a batch-job has its own overhead. Instead what you can do is you can create your subflows to process one or multiple records directly to the CRM. And these subflows would not contain their own batch. But, you can create a batch job after you are fetching your records, and, for each CRM subflow, you can create a batch:step
and define the required acceptExpression
to only send those records to the corresponding subflow.
It will look something like this:
<!-- your logic to fetch the records. -->
<batch:job jobName="all-crm-sync-batch-job">
<batch:process-records >
<batch:step name="crm1-sync-step" acceptExpression="#[payload.yourCrm1RelatedCondition == true]">
<flow-ref name="send-record-to-crm1-subflow" />
</batch:step>
<batch:step name="crm2-sync-step" acceptExpression="#[payload.yourCrm2RelatedCondition == true]">
<flow-ref name="send-record-to-crm2-subflow" />
</batch:step>
</batch:process-records>
</batch:job>
Upvotes: 1