简体   繁体   English

Mule 3 CE-文件处理顺序

[英]Mule 3 CE - File Processing Order

Good morning to everybody, I have a problem using Mule ESB CE with file order. 大家早上好,我在使用Mule ESB CE和文件顺序时遇到问题。 In the mule flow I have a File Inbound Endpoint that triggers the flow when one or more files come into a specified directory. 在the子流中,我有一个文件入站端点,当一个或多个文件进入指定目录时会触发该流。

Let's assume that i have three files (a.txt,b.txt,c.txt), and I'd like to process b.txt first then a.txt and finally, c.txt. 假设我有三个文件(a.txt,b.txt,c.txt),并且我想先处理b.txt,然后再处理a.txt,最后处理c.txt。

How can I do that? 我怎样才能做到这一点?

I read something about "File Processing Order" comparator that allows to write an own custom comparator but i did not find any example (neither in the Mule documentation). 我阅读了一些有关“文件处理顺序”比较器的信息,该比较器允许编写自己的自定义比较器,但是我没有找到任何示例(在Mule文档中都没有)。

Could anyone explain how to write a simple "file comparator" that order those files as above? 谁能解释如何编写一个简单的“文件比较器”来按上述顺序排列这些文件?

Thanks in advance. 提前致谢。 Best Regards PL 最好的问候PL

Just implement a custom comparator, and declare your file endpoint like this: 只需实现一个自定义比较器,然后像下面这样声明您的文件终结点:

<file:inbound-endpoint connector-ref="fileConnector"
       path="${path}" 
       moveToDirectory="${move.path}"
       moveToPattern="#[message.inboundProperties['originalFilename']]" 
       comparator="your.package.comparators.YourComparator"
/> 

Note that I've had some classloading problems using custom comparators with file endpoints(at least on 3.3.1 CE), notably this bug . 请注意,在使用带有文件端点的自定义比较器时(至少在3.3.1 CE上),我遇到了一些类加载问题,尤其是此bug

Let's assume that i have three files (a.txt,b.txt,c.txt), and I'd like to process b.txt first then a.txt and finally, c.txt. 假设我有三个文件(a.txt,b.txt,c.txt),并且我想先处理b.txt,然后再处理a.txt,最后处理c.txt。

How can I do that? 我怎样才能做到这一点?

As for the actual ordering, you need to use some collation to decide the order. 至于实际的订购,您需要使用一些排序规则来确定订购。 This may be simple, or very complicated. 这可能很简单,也可能非常复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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