骆驼动态uri参数

时间:2011-01-29 19:46:08

标签: apache-camel enterprise-integration

我想用骆驼这样实现content enricher pattern

from("direct:x").enrich(dynamicUri,new MyAggregatorStrategy()).to("direct:y")

动态uri基于来自direct:x频道的每条消息。 因此,假设有一个xml项,其值为a,而uri应该像http://someurl?q=a,但dynamicUri只能是资源通道标识符。 我找到了关于这个here的一些讨论,但我真的不明白它和“HttpProducer.HTTP_URI”在我的工作区中不可用,我需要这个camel包吗?我怎么做这个,处理器可能?但是如何?

1 个答案:

答案 0 :(得分:2)

您使用的是哪个版本的Camel?

许多键的常量名称已移至Camel 2.0以后的org.apache.camel.Exchange类。所以看看这个类的HTTP_URI常量。 这也是维基页面上列出的内容 http://camel.apache.org/http

Content Enricher不支持动态URI,但某些Camel组件允许将uri设置为标头;比如camel-http。在您的情况下,您可以使用常量Exchange.HTTP_URI将uri作为标题提供。

然而,据说,Camel中的收件人列表EIP模式实际上支持完全动态地评估URI,并且它还支持聚合。 http://camel.apache.org/recipient-list.html

所以你可以实现这样的解决方案:

from("direct:x")
    .recipientList(header("dynamicUriHeader")).aggregationStrategy(new MyOwnAggregationStrategy())
    .to("direct:y");
相关问题