在mule流程中,我已经迭代了upsertResults并在流程阶段将其添加到arraylist中,但有时它没有显示确切的结果,因为它基于批量大小而不断改变我认为。而且我也无法在Oncomplete阶段访问flowvars。在此我添加了我的mule配置代码,
<batch:job name="Student-Application-Upsert-Batch" max-failed-records="-1">
<batch:threading-profile poolExhaustedAction="WAIT"/>
<batch:input>
<data-mapper:transform doc:name="CSV To List<Account>" config-ref="CSV_To_List_Account_" stream="true"/>
</batch:input>
<batch:process-records>
<batch:step name="Upsert-Account">
<batch:commit doc:name="Batch Commit" streaming="true">
<sfdc:upsert config-ref="Salesforce__Basic_authentication" externalIdFieldName="Email_Address_Key__c" type="Account" doc:name="Upsert Account">
<sfdc:objects ref="#[payload]"/>
</sfdc:upsert>
<foreach doc:name="For Each Result Record" >
<choice doc:name="Choice">
<when expression="#[payload.success == 'true']">
<set-variable variableName="Success" value="#[SuccessResult.add(message.payload)]" doc:name="Success Records"/>
</when>
<otherwise>
<set-variable variableName="Failure" value="#[FailureResult.add(message.payload)]" doc:name="Failure Records"/>
</otherwise>
</choice>
</foreach>
<logger message="#####------------->Failures: #[flowVars.FailureResult.size()]" level="INFO" doc:name="Log Failure Records"/>
<logger message="#####------------->Success: #[flowVars.SuccessResult.size()]" level="INFO" doc:name="Log Success Records"/>
<object-to-string-transformer doc:name="Object to String"/>
<file:outbound-endpoint path="${MULE.PROCESSED_FILES}" outputPattern="#[flowVars.UpsertLogName]" connector-ref="LogFileWritter" responseTimeout="10000" doc:name="Upsert Results Log File"/>
</batch:commit>
</batch:step>
<batch:step name="Log-Failures" accept-policy="ONLY_FAILURES">
<logger message="Record with the following payload has failed. Payload:: #[message.payload], Loading Phase: #[failureExceptionForStep], Inside Failure the exception is :- #[getStepExceptions()]" level="INFO" doc:name="Log Failure"/>
<!-- <foreach collection="#[payload]" doc:name="For Each">
<logger message="For earch resultset row Payload is #[message.payload], counter is #[flowVars['counter']]" level="INFO" doc:name="Logger"/>
</foreach>-->
<object-to-string-transformer doc:name="Object to String"/>
<file:outbound-endpoint path="${MULE.FAILURE_LOGS}" outputPattern="OnlyFailures_#[message.inboundProperties.originalFilename].txt" responseTimeout="10000" doc:name="File" connector-ref="LogFileWritter"/>
</batch:step>
</batch:process-records>
<batch:on-complete>
<logger message="Batch Failed Records: #[payload.failedRecords]" level="INFO" doc:name="Logger"/>
<logger message="#####------------->Failures: #[flowVars.FailureResult.size()]" level="INFO" doc:name="Failure Size Logger"/>
<logger message="Number of failed Records: #[payload.failedRecords] " level="INFO" doc:name="Failed Records" />
<logger level="INFO" doc:name="Logger" message=" Number of loadedRecord: #[payload.loadedRecords]"/>
<logger message="Number of successful Records: #[flowVars.SuccessResult.size()]" level="INFO" doc:name="Successful Records" />
<logger message="ElapsedTime #[payload.getElapsedTimeInMillis()]" level="INFO" doc:name="Elapsed Time" />
</batch:on-complete>
</batch:job>
答案 0 :(得分:0)
您可以在完成时看到flowVars,但是您在步骤中对它们执行的操作可能不会在您使用该消息副本的每个步骤中传播。由于您无法在完成时看到它们,因此FYI记录变量无法做到。
我认为你在这里拥有的最佳选择是使用对象存储或自定义代码(如java bean)来存储要在完成时访问的值。注意并发性,因为在最后一步中写入该值可能会由多个线程运行,并由您来同步它们(对象存储不会帮助您实现这一点)。
HTH。