Versions Compared

Key

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

Tracer Example

...

Introduction

This 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:

  • how a given Exchange was routed
  • a snapshot of the content of the Exchange at any given node it passed in the route

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.

Requirements

This requires Camel 2.0, the camel-jpa component and configuration of the target database.

Camel uses the org.apache.camel.processor.interceptor.JpaTraceEventMessage JPA @Entity as data model.
This class has been enhanced with JPA annotations. The class has the following properties in the JPA model:

Property

Type

Description

Id

Long

Primary key that is generated by the database

Timestamp

Date

Timestamp when the snapshot was generated. Is the system time of the JMV in which Camel is running

FromEndpoint

String

the URI of the starting consumer the Exchange was created (usually a from in the route).

PreviousNode

String

id of the previous step in the route. Is null if there wasn't a previous node such as the start.

ToNode

String

id of the next step in the route

ExchangeId

String

unique id of the Exchange

ShortExchangeId

String

id of the Exchange without the machine name

ExchangePattern

String

The Exchange Pattern such as InOnly or InOut

Properties

String

The Exchange properties dumped as a String

Headers

String

The Exchange IN headers dumped as a String

Body

String

The Exchange IN body dumped as a String

BodyType

String

The Exchange IN body java type such as String, org.w3c.Document, com.mycompany.MyOrder etc.

OutHeaders

String

The Exchange OUT headers dumped as a String

OutBody

String

The Exchange OUT body dumped as a String

OutBodyType

String

The Exchange OUT body java type such as String, org.w3c.Document, com.mycompany.MyOrder etc.

causedByException

String

The Exchange exception (if any) dumped as a String including stacktrace

The table name for persisting trace events is: CAMEL_MESSAGETRACED

See also