【问题标题】:Unable to set CSV as payload in Mule无法在 Mule 中将 CSV 设置为有效负载
【发布时间】:2023-03-13 04:23:01
【问题描述】:

我正在尝试在 Mule 3.7.3 中创建一个流程,该流程从输入文件夹中读取 CSV 文件,进行一些处理,然后当一切都成功完成后,将原始 CSV 文件写入流程末尾的输出文件夹.

我想我会将 CSV 保存在一个变量中,然后使用该变量设置有效负载,然后再在输出目录中创建文件。

当我只有两个 sftp 连接器可以在流中读取和写入时,一切正常,但是当我添加一个转换消息连接器时,写入输出文件夹的文件为空或失败并出现“流关闭”错误信息。我本以为设置的有效负载连接器会覆盖转换消息,所以不会想到会有问题。

有谁知道我该如何解决这个问题?

我使用的 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

【问题讨论】:

    标签: csv mule sftp anypoint-studio


    【解决方案1】:

    &lt;sftp&gt; 连接器之后执行&lt;object-to-string-transformer/&gt;

    【讨论】:

    • 谢谢。我刚刚同时解决了这个问题:)
    猜你喜欢
    • 2015-03-20
    • 1970-01-01
    • 2014-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多