Apache的骆驼:从部分设置父交换性能(分割) [英] Apache Camel: Setting properties for parent exchange from its parts (split)

查看:153
本文介绍了Apache的骆驼:从部分设置父交换性能(分割)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了这DECOM presses文件并分割它没有台词(使用Unix命令'分裂'的话)的基础上交换分离器。返回包含这些零件的邮件信息列表。

I created a splitter for an exchange which decompresses the file and splits it on the basis of no of lines (Using Unix command 'split' for it). Returning list of messages containing these parts as messages.

然后在这些设置的一些特性,其需要被独立地处理。进一步父交换需要这些部件在完成后进行处理。现在,我需要对孩子设置几个属性要对父设置得。但是,我可以把它的唯一方法是重新编写的setProperty一部分。是否有这可能没有冗余可以实现任何方式。

Then set some properties on these as they need to be processed independently. Further the parent exchange needs to be processed after these parts are done. Now, I need a few properties set on the child to be set on the parent too. But the only way I could think of it was re-writing the setProperty part. Is there any way this could be achieved without redundancy.

我也尝试用另一种方式,即父设置属性,并试图访问这些对孩子是不是工作压力太大。

I did try it another way, i.e., setting properties on the parent and trying to access them on the children isn't working too.

for (String feed: pc.parseUri("{{feedSources}}").split(",")) {
        from("{{"+feed +".source}}").routeId(feed)
        .setProperty("workDirectory", simple("{{workDirectory}}"))
        .setProperty("feedName", simple(feed))
        .setProperty("tableName", simple("{{"+feed+".tableName}}"))
        .setProperty("options", simple("{{"+feed+".options}}"))
        .split(beanExpression(new FileSplitter(), "split"))
        .setProperty("dateFormat", simple("{{" + feed + ".dateFormat}}"))
        .setProperty("headerFormat", simple("{{" + feed + ".headerFormat}}"))
        .process(FileKeyProcessorFactory.getProcessor(feed))
        .to("{{"+feed+".destination}}")
        .end()
        .process(new RSProcessor());

有一些更多的属性进行设置。重写code似乎并不好看。还有什么可能的选项。

There are a few more properties to be set. Rewriting the code doesn't seems nice. What else could be the option.

推荐答案

使用的 AggregationStrategy 上分器从各分裂信息更改合并到的传出消息父母分离器。

Use an AggregationStrategy on the Splitter to merge in changes from each splitted message into the outgoing message of the parent splitter.

您可以阅读更多关于这个在: http://camel.apache.org/splitter 并在支持其他生态工业园区的 AggregationStrategy 以及

You can read more about this at: http://camel.apache.org/splitter and at other EIPs which support the AggregationStrategy as well.

这篇关于Apache的骆驼:从部分设置父交换性能(分割)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆