Mangoski
Mangoski

Reputation: 2119

To make until successful synchronous in mule 3.4

Below is a part of my mule flow

     <until-successful objectStore-ref="ObjStreuntil" maxRetries="60"              
secondsBetweenRetries="60" doc:name="Until Successful" failureExpression="#   [payload.state == 'Queued' || payload.state == 'InProgress']">
       <processor-chain doc:name="Processor Chain">
       <sfdc:batch-info config-ref="Salesforce" doc:name="Salesforce">
          <sfdc:batch-info ref="#[payload]"/>
       </sfdc:batch-info>
       <logger message="#[payload]" level="INFO" doc:name="Logger"/>
       </processor-chain>
       </until-successful>

I would like my flow to wait until my batch is completed and then proceed to the next processor. I believed using processing chain will get the outcome.

But the flow doesn't work. I'm aware that until sucessfull is made synchronos in 3.5 is there any method to acheive this on 3.4.0

Any suggestions would be of great help

Thank you in advance

Upvotes: 0

Views: 666

Answers (1)

Ryan Carter
Ryan Carter

Reputation: 11606

This was already answered here: to make until successful synchronous in mule 3.4

But if you want to perform something only when the batch is complete, you will need to check the status again, inverse to your failureExpression.

Something like:

<flow name="main">
        <until-successful objectStore-ref="ObjStreuntil"
            maxRetries="60" secondsBetweenRetries="60" doc:name="Until Successful"
            failureExpression="#[payload.state == 'Queued' || payload.state == 'InProgress']">
            <flow-ref name="checkBatch" />
        </until-successful>
    </flow>

    <sub-flow name="checkBatch">
        <sfdc:batch-info config-ref="Salesforce" doc:name="Salesforce">
            <sfdc:batch-info ref="#[payload]" />
        </sfdc:batch-info>
        <choice>
            <when expression="#[payload.state == 'Completed'">
                <!-- Do what needs to be done next -->
            </when>
            <otherwise>
                <!-- Do nothing so the until-successful retries -->
            </otherwise>
        </choice>
    </sub-flow>

As the other post describes, you can use with this with the request-reply if you really need to return to the main flow. You can put the until successful behind a vm endpoint and use that as the "request" phase and have the when expression above write to a reply queue.

Upvotes: 1

Related Questions