【问题标题】:move files with mule用骡子移动文件
【发布时间】:2013-10-10 09:45:55
【问题描述】:

我想使用 Mule 来移动和处理文件。我正在尝试使用流和“所有路由器”将相同的文件移动到不同的文件夹,但它失败了。

这行得通:

    <flow name="testflow2Flow1" doc:name="testflow2Flow1">
    <file:inbound-endpoint path="C:\IN" fileAge="10000" responseTimeout="10000" doc:name="File"/>
    <set-variable variableName="tempfilename" value="#[header:originalFilename]" doc:name="Variable"/>
    <file:outbound-endpoint path="C:\OUT" responseTimeout="10000" doc:name="File"/>
</flow>

但这不是!

    <flow name="testflow2Flow1" doc:name="testflow2Flow1">
    <file:inbound-endpoint path="C:\IN" fileAge="10000" responseTimeout="10000" doc:name="File"/>
    <set-variable variableName="tempfilename" value="#[header:originalFilename]" doc:name="Variable"/>
    <all doc:name="All">
        <processor-chain>
            <file:outbound-endpoint path="C:\OUT" responseTimeout="10000" doc:name="File"/>
        </processor-chain>
    </all>
</flow>

我得到了这个例外:

INFO 2013-10-03 20:22:19,072 [[testflow2].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver:在文件中获得锁定:C:\IN \test.txt.txt 错误 2013-10-03 20:22:19,088 [[testflow2].testflow2Flow1.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy:


消息:无法复制带有流有效负载的消息。有效载荷类型是“org.mule.transport.file.ReceiverFileInputStream”。消息负载的类型:ReceiverFileInputStream

代码:MULE_ERROR--2

异常堆栈是: 1. 无法复制带有流有效负载的消息。有效载荷类型是“org.mule.transport.file.ReceiverFileInputStream”。消息负载类型:ReceiverFileInputStream (org.mule.api.MessagingException)

org.mule.routing.outbound.AbstractSequenceRouter:74 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)

根异常堆栈跟踪: org.mule.api.MessagingException:无法使用流有效负载复制消息。有效载荷类型是“org.mule.transport.file.ReceiverFileInputStream”。消息有效负载的类型:ReceiverFileInputStream 在 org.mule.routing.outbound.AbstractSequenceRouter.route(AbstractSequenceRouter.java:74) 在 org.mule.routing.outbound.AbstractOutboundRouter$1.process(AbstractOutboundRouter.java:105) 在 org.mule.routing.outbound.AbstractOutboundRouter$1.process(AbstractOutboundRouter.java:100) + 3 个以上(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 为所有内容)


【问题讨论】:

  • 请分享您的 mule 配置
  • 现在我添加了 XML 配置。我不明白为什么添加所有路由器会破坏功能。
  • 你遇到了什么异常?
  • 感谢学习者,我遇到了类似的问题,并通过转到全局元素中的文件参考并将我的流媒体值更改为“假”来解决它!非常感谢。

标签: file copy mule


【解决方案1】:

您需要将 InputFileStream 转换为字节数组。 设置一个全局转换器(转到文件连接器属性--> 转换器--> 添加)。 选择文件到字节数组选项。连接器配置将如下所示。

file:inbound-endpoint path="C:\File Input" responseTimeout="10000" transformer-refs="File_to_Byte_Array" doc:name="File"/>

InputFileStream 不能原样复制到变量中。

【讨论】:

    【解决方案2】:

    在您的入站端点之后添加这个 &lt;object-to-byte-array-transformer/&gt; 转换器将使其工作。

    <flow name="testflow2Flow1" doc:name="testflow2Flow1">
        <file:inbound-endpoint path="C:\IN" fileAge="10000" responseTimeout="10000" doc:name="File"/>
        <object-to-byte-array-transformer/>
        <set-variable variableName="tempfilename" value="#[header:originalFilename]" doc:name="Variable"/>
        <all doc:name="All">            
            <file:outbound-endpoint path="C:\OUT" responseTimeout="10000" doc:name="File"/>
            <file:outbound-endpoint path="C:\OUT1" responseTimeout="10000" doc:name="File"/>        
        </all>
    </flow>
    

    我认为它失败的原因是因为 mule 试图以流的形式读取文件并以流的形式写入;在你的第一种情况下这很好。

    但是在第二个流程中,因为您想写入多个地方,所以流式传输是不可能的。添加此转换器后,现在您在内存中拥有完整的有效负载,并且可以写入多个。

    【讨论】:

      猜你喜欢
      • 2015-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多