简体   繁体   中英

processing one record in mule batch

Mule batch does not process single record. We have a scenario where we will be getting encrypted file with 1 to 20k records. Below is my Mule Flow. When we pass a single record file the process fails saying "must be of type interface java.lang.Iterable". Any suggestion on how to make make the flow work when one record file is recieved. Note : Flow works fine for file with multiple records.

Exception stack is:

1. Object "java.util.LinkedHashMap" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException) org.mule.util.collection.EventToMessageSequenceSplittingStrategy:64 (null) 2. Object "java.util.LinkedHashMap" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException) (com.mulesoft.module.batch.exception.BatchException) com.mulesoft.module.batch.engine.DefaultBatchEngine:366 (null)


Root Exception stack trace: java.lang.IllegalArgumentException: Object "java.util.LinkedHashMap" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}"

<context:property-placeholder location="dev.properties"/>
<encryption:config name="Encryption" defaultEncrypter="PGP_ENCRYPTER" doc:name="Encryption">
<encryption:pgp-encrypter-config publicKeyRingFileName="keys/dev_pgp_wd_ecc_public.key.gpg" secretKeyRingFileName="keys/dev_pgp_wd_ecc_private.key.gpg" secretAliasId="${key.AliasId}" secretPassphrase="${key.Passphrase}" principal="${key.principal}"/>
</encryption:config>

<amqp:connector name="AMQP_Connector" validateConnections="true" host="${amqp.host}" doc:name="AMQP Connector" virtualHost="${amqp.virtualhost}" password="${amqp.password}" port="${amqp.port}" username="${amqp.user}"/>
<http:request-config name="HTTP_Request_PI" host="${pi.endpoint}" port="${pi.port}" doc:name="HTTP Request Configuration" basePath="${pi.path}" responseTimeout="30000">
<http:basic-authentication username="${pi.username}" password="${pi.password}"/>
</http:request-config>
<smtp:connector name="SMTP_Alert" contentType="text/html" validateConnections="true" doc:name="SMTP"/>
<sftp:connector name="SFTP_Inbound_Connector" validateConnections="true" autoDelete="true" pollingFrequency="120000" doc:name="SFTP"/>
<batch:job name="TestBatch" max-failed-records="-1">
<batch:input>
    <sftp:inbound-endpoint connector-ref="SFTP_Inbound_Connector" host="${sftp.host}" port="${sftp.port}" path="/test/incoming/lt" user="${sftp.user}" password="${sftp.password}" responseTimeout="10000" doc:name="SFTP"/>

    <encryption:decrypt config-ref="Encryption" using="PGP_ENCRYPTER" doc:name="Encryption"/>
    <object-to-string-transformer doc:name="Object to String"/>
    <logger message="Decrypted" level="INFO" doc:name="Logger"/>
    <splitter expression="#[xpath3('/wd:Report_Data/wd:Report_Entry', payload, 'NODESET')]" doc:name="Splitter"/>
    <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
    <dw:transform-message doc:name="Transform Message" metadata:id="b7cbbbbb-d58b-439b-8684-5a6d0345d48c">
        <dw:input-payload doc:sample="empty.xml"/>
        <dw:set-payload></dw:set-payload>
    </dw:transform-message>
</batch:input>
<batch:process-records>
    <batch:step name="Batch_Step1">
        <json:object-to-json-transformer doc:name="Object to JSON"/>

            <amqp:outbound-endpoint exchangeName="${amqp.exchangeName}" queueName="${amqp.queueName}" responseTimeout="10000" encoding="UTF-8"  connector-ref="AMQP_Connector" doc:name="AMQP"/>

    </batch:step>

</batch:process-records>
<batch:on-complete>
    <logger message="#[flowVars.totalRecords.totalRecords]" level="INFO" doc:name="Logger"/>
    <logger message="#[flowVars.failedReocrds.failedReocrds]" level="INFO" doc:name="Logger"/>            
    <set-payload value="${mail.html}" doc:name="Set Payload" mimeType="text/html"/>
    <smtp:outbound-endpoint host="${mail.host}" port="${mail.port}" user="${mail.user}" password="${mail.password}" connector-ref="SMTP_Alert" to="${mail.receiver}" from="${mail.from}" subject="${IntegrationName}" responseTimeout="10000" doc:name="SMTP"/>
</batch:on-complete>

我在分割器之后包含了collection-aggregator,现在批处理适用于一个记录方案。

<collection-aggregator failOnTimeout="true" doc:name="Collection Aggregator"/>

You have to add a data mapper to transform the payload into a collection of maps. In the output of the data mapper choose Map<k,v> .

Your payload going into the batch processor is of type LinkedHashMap and it doesn't like it. It has to be a collection of maps. The data mapper will perform this transformation.

It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}"

我在分割器之后包含了collection-aggregator,现在批处理适用于一个记录方案

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM