【问题标题】:Mule flow not able to read the inbound attachmnetMule 流无法读取入站附件
【发布时间】:2017-07-27 23:15:49
【问题描述】:

我有这个 mule 流,它轮询源文件夹以读取我作为附件添加并通过 REST 调用发送的文本文件,我试图在不同的流中读取相同的附件,但入站附件即将到来作为 null ,请查看代码并帮助我。

<flow name="createAttachment" doc:description="Reading file and sending as attachment.">
    <file:inbound-endpoint path="src/test/resources/in/attachment/" responseTimeout="10000" doc:name="File"/>
    <file:file-to-byte-array-transformer doc:name="File to Byte Array"/>
 <!--    <set-attachment attachmentName="#[originalFilename]" value="#[payload]" contentType="multipart/form-data" doc:name="Attachment"/>  -->
  <set-attachment attachmentName="#[originalFilename]" value="#[payload]" contentType="multipart/form-data" doc:name="Attachment" />
    <http:request config-ref="HTTP_Request_Configuration" path="attachment/excel"  method="POST" doc:name="HTTP"/>
</flow>


<flow name="readAttachment">
 <http:listener config-ref="HTTP_Listener_Configuration" path="attachment/excel" allowedMethods="POST" parseRequest="false" />
    <set-payload value="#[message.inboundAttachments['myattachment.txt']]" doc:name="Retrieve Attachments"/> 
      <set-payload value="#[payload.getInputStream() ]" doc:name="Get Inputstream from Payload"/>
        <file:outbound-endpoint path="src/test/resources/out/attachment" responseTimeout="10000" doc:name="File" outputPattern="#[server.dateTime.toString()].pdf"/>

</flow>

【问题讨论】:

    标签: mule mule-studio mule-component mule-esb


    【解决方案1】:

    我使用了以下内容:

    <flow name="readAttachment">
        <http:listener config-ref="HTTP_Listener_Configuration"
            path="/" allowedMethods="POST" parseRequest="false" doc:name="HTTP" />
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <logger message="#[payload]" level="INFO" doc:name="Logger" /><file:outbound-endpoint path="src/test/resources" connector-ref="File" responseTimeout="10000" doc:name="File"/>
    
    </flow>
    

    收到附件后,它会自动解析为有效负载,因此只是将字节数组转换为字符串的情况。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-22
      • 1970-01-01
      • 2019-04-10
      • 2020-04-09
      • 1970-01-01
      相关资源
      最近更新 更多