Versions Compared

Key

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

...

We receive an Exchange from the in stream, then its split using the splitWords method. Then the quote method is invoked before its aggregated and finally sent to the stream out to be printed in the console.

Trace the routing

If we look at the 6 rows from the traced SQL (the first picture) and with the route diagram in mind we can get a better understand how the Exchange was routed.

1. The Exchange does not have a previousNode so its the first step where its consumed from the input stream and that its going to the splitter.
2. The exchange id has changed and this is the output of the splitter as it creates a new Exchange. We can also see this one has one word in the body. This Exchange is being routed to the quote bean next.
3. This is the 2nd output from the splitter containing the 2nd word. This Exchange is being routed to the quote bean next.
4. This is the Beer Exchange where we can see the output from the quote server and that its being routed to the aggregator.
5. This is the Camel Exchange where we can see the output from the quote server and that its being routed to the aggregator.
6. This is the result of the aggregator where the Exchange ending with id 0-2 "was the winner" and is being routed as the aggregated result to the stream out.

Configuration of JPA tracing in Camel

In Camel you need to configure it to use JPA for tracing. We do this as by adding a tracer in the META-INF/camel-context.mxl file:

Wiki Markup
{snippet:id=e1|lang=xml|url=activemq/camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml}

To properly configure JPA for tracing we must complete these two steps:
1. enable the JPA tracing by setting the property useJpa=true
2. set the destination or destinationUri to a JPA producer endpoint

In this example we set the desintation that refers to a endpoint we define in the camel context:

Wiki Markup
{snippet:id=e3|lang=xml|url=activemq/camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml}

Here its important that the endpoint is configure with the {org.apache.camel.processor.interceptor.JpaTraceEventMessage}} as entity name and the persistenceUnit as an option. In out example we use tracer.

Then the following is standard Spring JPA configuration:

Wiki Markup
{snippet:id=e2|lang=xml|url=activemq/camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml}

However we must set the persistenceUnitName to the same unit name we defined in persistence.xml, such as tracer as we are using in this example.

And if you are wondering how the Camel route is defined then its here:

Wiki Markup
{snippet:id=e4|lang=xml|url=activemq/camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml}

See also