Question

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

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

The dynamic uri is based on each message which comes from the direct:x channel. So lets say there is an xml item comming in with the value a than 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?

Was it helpful?

Solution

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");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top