简体   繁体   中英

Mule: Two file outbound endpoint and one inbound endpoint to the same location issue

<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>    

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

My first two flows are have the same file outbound endpoint path and my third flow's inbound endpoint path is pointing to same folder location. I get the error:

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)

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

Can I have two outbound endpoints in a single flow, whose path is same as as inbound endpoint of another flow path?

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

.. ..

Try disabling streaming in your file connector:

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

Then in all of your file endpoints refer this connector.

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

// need to convert from an input stream to a byte array to avoid having the wire-tap close it

Adding above mentioned object-to-byte-array-transformer helped to convert input stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM