camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Direct-VM
Date Fri, 15 Jun 2012 11:57:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;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/Direct-VM">Direct-VM</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h2><a name="Direct-VM-DirectVMComponent"></a>Direct VM Component</h2>
<p><b>Available as of Camel 2.10</b></p>

<p>The <b>direct-vm:</b> component provides direct, synchronous invocation
of any consumers in the JVM when a producer sends a message exchange.<br/>
This endpoint can be used to connect existing routes in the same camel context, as well from
other camel contexts in the <b>same</b> JVM.</p>

<p>This component differs from the <a href="/confluence/display/CAMEL/Direct" title="Direct">Direct</a>
component in that <a href="/confluence/display/CAMEL/Direct-VM" title="Direct-VM">Direct&#45;VM</a>
supports communication across CamelContext instances - so you can use this mechanism to communicate
across web applications (provided that camel-core.jar is on the system/boot classpath).</p>

<p>At runtime you can swap in new consumers, by stopping the existing consumer(s) and
start new consumers.<br/>
But at any given time there can be at most only one active consumer for a given endpoint</p>

<h3><a name="Direct-VM-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
direct-vm:someName
</pre>
</div></div>

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint</p>

<h3><a name="Direct-VM-Samples"></a>Samples</h3>
<p>In the route below we use the direct component to link the two routes together:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"activemq:queue:order.in"</span>)
    .to(<span class="code-quote">"bean:orderServer?method=validate"</span>)
    .to(<span class="code-quote">"direct-vm:processOrder"</span>);
</pre>
</div></div>

<p>And now in another CamelContext, such as another OSGi bundle</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct-vm:processOrder"</span>)
    .to(<span class="code-quote">"bean:orderService?method=process"</span>)
    .to(<span class="code-quote">"activemq:queue:order.out"</span>);
</pre>
</div></div>

<p>And the sample using spring DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
   <span class="code-tag">&lt;route&gt;</span>
     <span class="code-tag">&lt;from uri=<span class="code-quote">"activemq:queue:order.in"</span>/&gt;</span>
     <span class="code-tag">&lt;to uri=<span class="code-quote">"bean:orderService?method=validate"</span>/&gt;</span>
     <span class="code-tag">&lt;to uri=<span class="code-quote">"direct-vm:processOrder"</span>/&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>

  <span class="code-tag">&lt;route&gt;</span>
     <span class="code-tag">&lt;from uri=<span class="code-quote">"direct-vm:processOrder"</span>/&gt;</span>
     <span class="code-tag">&lt;to uri=<span class="code-quote">"bean:orderService?method=process"</span>/&gt;</span>
     <span class="code-tag">&lt;to uri=<span class="code-quote">"activemq:queue:order.out"</span>/&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>    
</pre>
</div></div>

<h3><a name="Direct-VM-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Direct" title="Direct">Direct</a></li>
	<li><a href="/confluence/display/CAMEL/SEDA" title="SEDA">SEDA</a></li>
	<li><a href="/confluence/display/CAMEL/VM" title="VM">VM</a></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/Direct-VM">View Online</a>
              |
       <a href="https://cwiki.apache.org/confluence/display/CAMEL/Direct-VM?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message