2012-10-28 52 views
0

我正在嘗試編寫一個簡單的Mule Flow,用於監視目錄中的文件,然後將SFTP傳送到最終目的地。如果有大量的文件的SFTPs應在10Mule ForEach示例文件端點

組進行批處理了這裏是我的XML

<flow name="FileTransferUtilFlow1" doc:name="FileTransferUtilFlow1"> 
    <file:inbound-endpoint path="${source.dropbox.dir}" 
     moveToDirectory="${completed.dir}" responseTimeout="10000" doc:name="File"> 
     <file:filename-wildcard-filter pattern="*.txt" 
      caseSensitive="true" /> 
    </file:inbound-endpoint> 
    <async processingStrategy="Queued_Asynchronous_Processing_Strategy" 
     doc:name="Async"> 
     <foreach doc:name="Foreach" batchSize="10"> 
      <sftp:outbound-endpoint exchange-pattern="one-way" 
       host="192.168.1.14" port="22" path="${landing.dir}" user="myID" 
       password="xxyyzz" responseTimeout="10000" doc:name="SFTP" 
       outputPattern="#[header:originalFilename]" /> 
     </foreach> 
    </async> 
</flow> 

而這裏的錯誤:

java.lang.IllegalArgumentException: Object "org.mule.transport.file.ReceiverFileInputStream" not of correct type. It must be of type "interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection" 
at org.mule.routing.CollectionSplitter.splitMessageIntoSequence(CollectionSplitter.java:60) 
at org.mule.routing.Foreach$CollectionMapSplitter.splitMessageIntoSequence(Foreach.java:250) 
at org.mule.routing.outbound.AbstractMessageSequenceSplitter.process(AbstractMessageSequenceSplitter.java:60) 
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)} 

回答

1

在foreach範圍,如前所述由the documentation設計,用於拆分/聚合集合。相反,文件端點輪詢目錄中的每個文件並從中創建一條消息。

要實現您的目標,您需要引入一些明確的聚合策略。最好的方法是使用Custom Aggregator