【问题标题】:Mule Requester - FTP - payload type Byte Array not Input StreamMule Requester - FTP - 有效负载类型字节数组不是输入流
【发布时间】:2017-06-20 15:43:07
【问题描述】:

我正在处理一个非常大的 csv 文件并使用 Mule Requester 来读取文件的内容。 我配置了一个 ftp 连接器并将流设置为“true”,但是当我尝试记录有效负载时,我可以看到 Mule 请求器正在返回一个字节数组,这意味着它将文件的所有内容加载到内存中并且我不想那样。

这是我的流程:

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

    <mule xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns:mulerequester="http://www.mulesoft.org/schema/mule/mulerequester" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
    http://www.mulesoft.org/schema/mule/mulerequester http://www.mulesoft.org/schema/mule/mulerequester/current/mule-mulerequester.xsd
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.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/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
    http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd">
        <ftp:connector name="FTP" pollingFrequency="1000" streaming="true" validateConnections="true" doc:name="FTP"/>
        <flow name="mulerequesterstreamFlow1" processingStrategy="synchronous">
            <quartz:inbound-endpoint jobName="streamingTest" repeatInterval="15000" responseTimeout="10000" doc:name="Quartz">
                <quartz:event-generator-job/>
            </quartz:inbound-endpoint>
            <flow-ref name="mulerequesterstreamFlow" doc:name="mulerequesterstreamFlow"/>
        </flow>
        <flow name="mulerequesterstreamFlow" processingStrategy="synchronous">
            <mulerequester:request resource="ftp://vagrant:vagrant@192.168.1.9:21/home/vagrant/read_directory?connector=FTP" throwExceptionOnTimeout="true" doc:name="Mule Requester" />
            <choice doc:name="Choice">
                <when expression="#[payload != empty]">
                    <logger message="payload is not empty #[payload]" level="INFO" doc:name="Logger - payload"/>
                </when>
                <otherwise>
                    <logger message="empty payload" level="INFO" doc:name="Logger - log when payload is empty"/>
                </otherwise>
            </choice>
        </flow>
    </mule>

为简单起见,我删除了围绕这些流程但对于这个问题不是必需的其他逻辑。

以下是记录的内容:

payload is not empty [B@3ac94399

【问题讨论】:

  • 你为什么使用带有流引用的&lt;quartz:inbound-endpoint&gt; 而不是&lt;ftp:inbound-endpoint&gt;
  • 为简单起见,我删除了围绕这些流程的其他逻辑,但对于这个问题不是必需的。
  • 您使用的逻辑可能已将您的有效负载转换为某处的Byte[]mulerequesterchoice 之间有什么逻辑吗?
  • 嗨@PierreB。不,mulerequester 和选择之间没有逻辑,因此它不应该将有效负载转换为字节 []。上述流程工作并记录从 Mule Requester 返回的有效负载类型,其类型为 Byte[]。

标签: ftp mule esb


【解决方案1】:

每当您尝试传递 csv 文件时,请确保在选择范围之前使用转换器,并且在选择范围内拖动另一个转换器和记录器以获得结果,通过引用您的转换器来提及选择范围的“何时”条件在选择范围流内使用并将记录器放在每个范围内,以便它进行迭代。确保不要将转换器放在 foreach 范围内。

【讨论】:

  • 感谢您的回答,但这与我的问题无关。我的问题是我得到了一个字节 [] 类型的有效负载,我期望有一个流。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多