开发者

camel dynamic uri parameter

开发者 https://www.devze.com 2023-02-07 05:11 出处:网络
i want to implement the content enricher pattern with camel like this: from("direct:x").enrich(dynamicUri,new MyAggregatorStrategy()).to("dire开发者_StackOverflowct:y")

i want to implement the content enricher pattern with camel like this:

from("direct:x").enrich(dynamicUri,new MyAggregatorStrategy()).to("dire开发者_StackOverflowct:y")

The dynamic uri is based on each message which comes from the direct:x channel. So let's say there is an xml item coming in with the value a then the uri should be like http://someurl?q=a but the dynamicUri can only be a resource channel identifier.

I found some discussion on this here but i don't really understand it and the "HttpProducer.HTTP_URI" is not available in my workspace. Which camel package do I need for this and how do I do this? A processor maybe, but how?


What version of Camel are you using?

Many of those constant names for keys has been moved to to org.apache.camel.Exchange class in Camel 2.0 onwards. So take a look at this class for the HTTP_URI constant. That's also what's listed on the wiki page http://camel.apache.org/http

The Content Enricher doesn't support a dynamic URI, but some Camel components allow to set an uri as a header; such as the camel-http. Which mean in your case you can provide the uri as a header using the constant Exchange.HTTP_URI.

However that said, the Recipient List EIP pattern in Camel actually supports to evaluate the URI fully dynamic, and it also supports aggregation. http://camel.apache.org/recipient-list.html

So you could implement the solution like this:

from("direct:x")
    .recipientList(header("dynamicUriHeader")).aggregationStrategy(new MyOwnAggregationStrategy())
    .to("direct:y");
0

精彩评论

暂无评论...
验证码 换一张
取 消