Versions Compared

Key

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

...

If you want to log information all time taken to send and receive replies when sending to external endpoints, then you can leverage the Event Notifier EventNotifier in Camel. It allows you to subscribe to events and react upon them.

For example we want to log the time it takes to send to endpoints which can be done by implementing a class which this logic as follows: TODO: e1 -

Wiki Markup
{snippet:id=e1|lang=java|title=MyLoggingSentEventNotifier|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyLoggingSentEventNotifer.java}

Then in Java DSL you can tell Camel to use your custom EventNotifier simply by adding it:

...

And in Spring XML you declare a Spring bean and Camel will automatic pick it up: TODO: e1 -

Wiki Markup
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/EventNotifierExchangeSentExampleTest.xml}

If you run this example you will notice how Camel logs this now:

...

You can implement logic to filter which endpoints to log, and maybe also thresholds to skip logging if it was fast, e.g. < 1 sec.
Then you have a logger which logs all slow events.

Tip you can use the EndpointHelper.matchEndpoint method to leverage the same filtering capabilities that for example the Intercept uses in Camel.

You can see which EventObject Camel provides from the javadoc.