UuidGenerator

Camel supports 3rd party UUID generator(s).

A useful scenario is to use a simple counter for testing purpose. With this it is easier to correlate the exchanges in the log/debugger.

Camel uses UUIDs in the exchange and message ids, and other unique ids it uses.

You only have to implement org.apache.camel.spi.UuidGenerator and tell Camel, that it should use your custom implementation:

Configuring UuidGenerator

getContext().setUuidGenerator(new MyCustomUuidGenerator());

Camel will configure this UUID generator by doing a lookup in the Spring bean registry to find the bean of the type org.apache.camel.spi.UuidGenerator.

<bean id="simpleUuid" class="org.apache.camel.support.SimpleUuidGenerator" />

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
  <route>
    <from uri="direct:start" />
    <to uri="mock:result" />
  </route>
</camelContext>

Standard UUID Generators

Camel comes with the following implementations out of the box:

  • org.apache.camel.support.ClassicUuidGenerator - This is the classic Camel 2.x generator

  • org.apache.camel.support.DefaultUuidGenerator - Default generator (32 chars) optimized for Camel usage

  • org.apache.camel.support.ShortUuidGenerator - Is 50% the size of the default (16 chars) optimized for Camel usage

  • org.apache.camel.support.SimpleUuidGenerator - This implementation uses internally a java.util.concurrent.atomic.AtomicLong and increases the ID for every call by one. Starting with 1 as the first id.