...
intercept
interceptEndpoint
new in Camel 2.0 that intercepts when an Exchange is about to be sent to the given Endpoint
Intercept
Lets start with the logging example. We want to log all the incoming requests so we use intercept
to route to the Log component. As proceed
is default then the Exchange will continue its route, and thus it will continue to mock:first
.
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptorSimpleLogTest.java} |
InterceptEndpoint
Available as of Camel 2.0
...
Let start with a simple example, where we want to intercept when an Exchange is being sent to mock:foo
:
TODO: e1
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java} |
And this time we add the Predicate so its only when the message body is Hello World
we intercept.
TODO: e2
Wiki Markup |
---|
{snippet:id=e2|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java} |
And to skip sending to the mock:foo
endpoint we use the stop()
DSL in the route at the end to instruct Camel to skip sending. The name *stop() is used as the interceptEndpoint
builds on top of intercept
and thus we inherit the DSL ketwords.
TODO: e3keywords.
Wiki Markup |
---|
{snippet:id=e3|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/InterceptEndpointTest.java} |