...
Camel supports three kinds of interceptors:
intercept
that intercepts each and every processing step while routing an Exchange in the route.interceptFrom
that intercepts incoming Exchange in the route.interceptSendToEndpoint
that intercepts when an Exchange is about to be sent to the given Endpoint.
These interceptors supports the following features:
- Predicate using
when
to only trigger the interceptor in certain conditions stop
forces to stop continue routing the Exchange and mark it as completed successful. Camel will by default not stop.skip
when used withinterceptSendToEndpoint
will skip sending the Exchange to the original intended endpoint. Camel will by default not skip.interceptFrom
andinterceptSendToEndpoint
supports endpoint URI matching by: exact uri, wildcard, regular expression. See advanced section.- The intercepted endpoint uri is stored as message header
Exchange.INTERCEPTED_ENDPOINT
.
Tip | ||
---|---|---|
| ||
You can also instruct Camel to |
...
What happens is that the Exchange is intercepted before each processing step, that means that it will be intercepted before
.to("bean:validateOrder")
.to("bean:processOrder")
So in this sample we intercept the Exchange twice.
...
The interceptFrom
and interceptSendToEndpoint
supports endpoint URI matching by the following rules in the given order:
- match by exact URI name. This is the sample we have seen above.
- match by wildcard
- match by regular expression.
The real endpoint that was intercepted is stored as uri in the message IN header with the key Exchange.INTERCEPTED_ENDPOINT
.
This allows you to get hold of this information, when you for instance match by wildcard. Then you know the real endpoint that was intercepted and can react accordingly.
...
Info | ||
---|---|---|
| ||
The |