<html>
<head>
<base href="https://cwiki.apache.org/confluence">
<link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CAMEL&forWysiwyg=true"
type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/UuidGenerator">UuidGenerator</a></h2>
<h4>Page <b>added</b> by <a href="https://cwiki.apache.org/confluence/display/~muellerc">Christian
Mueller</a>
</h4>
<br/>
<div class="notificationGreySide">
<h2><a name="UuidGenerator-UuidGenerator"></a>UuidGenerator</h2>
<p>Starting with <b>Camel 2.5</b>, Camel supports 3rd part UUID generator.
This is useful, if e.g. your messaging provider does not support UUID's with a length of 36
characters (like Websphere MQ). Another useful scenario is to use a simple counter for testing
purpose. With this it is easier to correlate the exchanges in the log/debugger.</p>
<p>You only have to implement <tt>org.apache.camel.spi.UuidGenerator</tt>
and tell Camel, that it should use your custom implementation:</p>
<h3><a name="UuidGenerator-ConfiguringfromJavaDSL"></a>Configuring from
Java DSL</h3>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
getContext().setUuidGenerator(<span class="code-keyword">new</span> MyCustomUuidGenerator());
</pre>
</div></div>
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td>You should not change
the UUID generator at runtime (it should only be set once)!</td></tr></table></div>
<h3><a name="UuidGenerator-ConfiguringfromSpringDSL"></a>Configuring from
Spring DSL</h3>
<p>Camel will configure this UUID generator by doing a lookup in the Spring bean registry
to find the bean of the type <tt>org.apache.camel.spi.UuidGenerator</tt>.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<bean id=<span class="code-quote">"activeMQUuidGenerator"</span> class=<span
class="code-quote">"org.apache.camel.impl.ActiveMQUuidGenerator"</span> />
<camelContext id=<span class="code-quote">"camel"</span> xmlns=<span
class="code-quote">"http:<span class="code-comment">//camel.apache.org/schema/spring"</span>>
</span> <route>
<from uri=<span class="code-quote">"direct:start"</span> />
<to uri=<span class="code-quote">"mock:result"</span> />
</route>
</camelContext>
</pre>
</div></div>
<h3><a name="UuidGenerator-Providedimplementations"></a>Provided implementations</h3>
<p>Camel comes with three implementations of org.apache.camel.spi.UuidGenerator:</p>
<ul class="alternate" type="square">
<li><tt>org.apache.camel.impl.DefaultUuidGenerator</tt> - The default Camel
UUID generator which use <tt>java.util.UUID</tt>.</li>
<li><tt>org.apache.camel.impl.SimpleUuidGenerator</tt> - This implementation
use internally a <tt>java.util.concurrent.atomic.AtomicLong</tt> and increase
the ID for every call by one.</li>
<li><tt>org.apache.camel.impl.ActiveMQUuidGenerator</tt> - This implementation
use the ActiveMQ/Camel 1.x style of ID's.</li>
</ul>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;">
<a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
</div>
<a href="https://cwiki.apache.org/confluence/display/CAMEL/UuidGenerator">View
Online</a>
|
<a href="https://cwiki.apache.org/confluence/display/CAMEL/UuidGenerator?showComments=true&showCommentArea=true#addcomment">Add
Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
|