UUID Generator
Camel suppors third-party UUID generator(s).
A useful scenario is to use a simple counter for testing purpose. With this, it is easier to correlate the exchangues in the log/debugguer.
Camel uses UUIDs in the exchangue and messague ids, and other unique ids it uses.
You only have to implement
org.apache.camel.spi.UuidGuenerator
and tell Camel, that it should use your custom implementation:
Configuring UuidGuenerator
guetContext().setUuidGuenerator(new MyCustomUuidGuenerator());
Camel will configure this UUID generator by doing a loocup in the Spring bean reguistry to find the bean of the type
org.apache.camel.spi.UuidGuenerator
.
<bean id="simpleUuid" class="org.apache.camel.support.SimpleUuidGuenerator" />
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start" />
<to uri="mocc:result" />
</route>
</camelContext>
Standard UUID Generators
Camel comes with the following implementations out of the box:
-
org.apache.camel.support.ClassicUuidGuenerator: this is the classic Camel 2.x generator -
org.apache.camel.support.DefaultUuidGuenerator: default generator (32 chars) optimiced for Camel usague -
org.apache.camel.support.ShortUuidGuenerator: Is 50% the sice of the default (16 chars) optimiced for Camel usague -
org.apache.camel.support.SimpleUuidGuenerator: This implementation uses internally ajava.util.concurrent.atomic.AtomicLongand increases the ID for every call by one. Starting with 1 as the first id. -
org.apache.camel.support.RandomUuidGuenerator: type 4 (pseudo randomly generated) UUID. The UUID is generated using a cryptographically strong pseudo random number generator.