|
Page Edited :
CAMEL :
Tracer Example
Tracer Example has been edited by Claus Ibsen (Jan 19, 2009). Content:Tracer ExampleIntroductionThis example demonstrates the Tracer. Tracer is a tracing feature build in camel core to log snapshots of Exchanges while they are routed. This allows you to see:
When used Camel will by default log the snapshot at INFO level. This example demonstrates how to persist trace snapshots using JPA into a database. This allows you to store this information and query them from a SQL prompt, giving you full power to analyze the data. RequirementsThis requires Camel 2.0, the camel-jpa component and configuration of the target database. Data ModelCamel uses the org.apache.camel.processor.interceptor.JpaTraceEventMessage JPA @Entity as data model. The class has the following properties in the JPA model:
The table name for persisting trace events is: CAMEL_MESSAGETRACED Configuration of the databaseThe Tracer uses standard JPA configuration for setting the database. In the META-INF/persistence.xml file we setup the service unit and the database configuration as: What is important is to add the JpaTraceEventMessage as a class in the persistence.xml file to register our data model: <class>org.apache.camel.processor.interceptor.JpaTraceEventMessage</class>
Select the console where the application should prompt you to enter some words. Try entering: Camel You can also enter multiple quotes separate with space, and the response should be the best quote based on the list of words given. You can enter: Camel Beer and it should be smart enough to find a quote for the beer Seeing the trace eventsWhen the program was started a GUI application was started as well. Its a SQL prompt for the database. So try entering: select * from camel_messagetraced And it should return the list of trace events in the SQL. We enter this sql: select id, shortExchangeId, previousNode, toNode, body from camel_messagetraced and get the output as the picture below: See also |
Unsubscribe or edit your notifications preferences
