Mule:两个文件出站端点和一个入站端点到同一位置问题

时间:2014-08-26 18:51:40

标签: file path streaming mule endpoints

<flow name="flow1"..>
  ..
  <file:outbound-endpoint path="${workdir}/folder/inbox"/>
  ..
  ..
</flow>

<flow name="flow2"..>
  ..
  <file:outbound-endpoint path="${workdir}/folder/inbox"/>
  ..
  ..
</flow>

<flow name="flow3"..>
  <file:inbound-endpoint connector-ref="someConnector"
        path="${workdir}/folder/inbox"
        moveToDirectory="${global.workdir}/123"
        transformer-refs="Transformer"
        moveToPattern="#[header:originalFilename]-#[function:datestamp-yyyy-MM-dd_HH-mm-ss.SSS]" />
  ..
  ..
</flow>    

=============================================== ==

我的前两个流具有相同的文件出站端点路径,而我的第三个流的入站端点路径指向相同的文件夹位置。我收到错误:

Message               : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file://C:/temp/mule/data/vendors/inbound/856, connector=FileConnector
{
  name=inboundFileConnector
  lifecycle=start
  this=c4092f
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[file]
  serviceOverrides=<none>
}
,  name='endpoint.C.mule.data.vendors.inbound.856', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ReceiverFileInputStream
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Stream Closed (java.io.IOException)
  java.io.FileInputStream:-2 (null)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=file://C:/mule/data/vendors/856, connector=FileConnector
{
  name=inboundFileConnector
  lifecycle=start
  this=c4092f
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[file]
  serviceOverrides=<none>
}
,  name='endpoint.C..mule.data.vendors.in.856', mep=ONE_WAY, properties={}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ReceiverFileInputStream (org.mule.api.transport.DispatchException)
  org.mule.transport.AbstractMessageDispatcher:109 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.io.IOException: Stream Closed
    at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(Unknown Source)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1025)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

=============================================== ==

我可以在一个流中有两个出站端点,其路径与另一个流路径的入站端点相同吗?

<flow name="flow1"..>
  ..
  <file:outbound-endpoint path="${workdir}/folder/inbox"/>
  ..
  ..
  <file:outbound-endpoint path="${workdir}/folder/inbox"/>
  ..
</flow>

             ..       ..     

2 个答案:

答案 0 :(得分:1)

尝试在文件连接器中禁用流媒体:

<file:connector name="sampleFileConnector"  streaming="false" ></file:connector> 

然后在所有文件端点中引用此连接器。

<file:outbound-endpoint connector-ref="sampleFileConnector" path="${workdir}/folder/inbox"/>

答案 1 :(得分:1)

<object-to-byte-array-transformer/>     

//需要从输入流转换为字节数组,以避免有线关闭它

添加上面提到的object-to-byte-array-transformer有助于转换输入流。