Невозможно установить CSV в качестве полезной нагрузки в Mule

#csv #mule #sftp #anypoint-studio

#csv #mule #sftp #anypoint-studio

Вопрос:

Я пытаюсь создать поток в Mule 3.7.3, который считывает CSV-файл из входной папки, выполняет некоторую обработку, а затем записывает исходный CSV-файл в выходную папку в конце потока, когда все успешно завершено.

Я думал, что сохраню CSV в переменной, а затем установлю полезную нагрузку, используя эту переменную, прежде чем она создаст файл в выходном каталоге.

Все работало нормально, когда у меня были только два sftp-соединителя для чтения и записи в потоке, но затем, когда я добавил соединитель сообщений преобразования, файл, записанный в выходную папку, пуст или завершается ошибкой с сообщением об ошибке «поток закрыт». Я бы ожидал, что соединитель set payload перезапишет сообщение transform, поэтому не думал, что возникнет проблема.

Кто-нибудь знает, как я могу это исправить?

Сервер SFTP, который я использую, — это CrushFTP.

Поток XML:

 <?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <http:request-config name="HTTP_Request_Configuration" host="${host}" port="${orderprocess.port}" doc:name="HTTP Request Configuration"></http:request-config>
    <sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP" pollingFrequency="1000000"/>
    <flow name="userFlow">
        <sftp:inbound-endpoint connector-ref="SFTP" host="localhost" port="2222" path="//input" user="${ftp.user}" password="${ftp.password}" responseTimeout="10000" doc:name="SFTP"/>
        <set-variable variableName="storeCsv" value="#[payload]" mimeType="application/csv" doc:name="Store CSV"/>
        <dw:transform-message doc:name="Transform Message">
            <dw:input-payload mimeType="application/csv"/>
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload]]></dw:set-payload>
        </dw:transform-message>
        <set-payload value="#[flowVars.storeCsv]" mimeType="application/csv" doc:name="Set Payload"/>
        <sftp:outbound-endpoint exchange-pattern="one-way" host="localhost" port="2222" responseTimeout="10000" doc:name="SFTP" connector-ref="SFTP" password="${ftp.password}" path="//output" user="${ftp.user}" outputPattern="#[message.inboundProperties.originalFilename '.processed']"/>
    </flow>  
</mule>
  

Файл CSV

 1, user1
  

Ответ №1:

Выполнить <object-to-string-transformer/> после <sftp> соединителя

Комментарии:

1. Спасибо. Я только что понял это одновременно 🙂