Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
// lets log messages from gold customers
intercept(xpath("/customer[@type='gold']").to("log:customer").proceed();

from("seda:foo").to("seda:bar");

Changes in Camel 1.4

In Camel 1.4 proceed() is now default, so the examples above can be written as:

Code Block

// lets log all steps in all routes
intercept().to("log:foo");

from("seda:foo").to("seda:bar");

Proceed means that Camel will continue the normal route path after the interception. All the examples shown is logging examples where the routing is supposed to continue by its normal path. Camel is so powerful that you can also use interceptors to alter the route path and change the cause of action.
The example below will intercept all exchanges that has an istest flag set to true and move the exchange to a test queue. We append the stop() to indicate that the interceptor should not proceed - thus any istest message is intercepted and does not route in the normal route path, but is moved to the test queue.

Code Block

intercept(header("istest").isEqualTo("test")).to("seda:test").stop();

See Also

For more examples of the DSL in action see

...