Question

I am trying to intercept an endpoint where the value of the URI matches some information in the exchange header.

Let say I have a field in the header called DatabaseName. I want to enforce that a specific route is only writing to the database specified in the header.

Can I do something like this?

interceptSendToEndpoint("mock:${in.header.DatabaseName}")

I tried that but it does not seem to work. What are my options?

I was also thinking of doing something like:

interceptSendToEndpoint("mock:*").when(...)?

But in this case, I am not sure if I can reference the URI of the intercepted node in the when expression.

Thanks

Was it helpful?

Solution

You can intercept using a wildcard and combine that with when to do what you want, see details at: http://camel.apache.org/intercept

The is a header on the Message with the key Exchange.INTERCEPTED_ENDPOINT (CamelInterceptedEndpoint) that has the endpoint uri that was intercepted. You can use that in the when to match the predicate. Something a like:

interceptSendToEndpoint("mock:*")
  .when(simple("${header.CamelInterceptedEndpoint} == ${in.header.DatabaseName}"))
  ...

OTHER TIPS

Use the recipientList instruction for this: http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top