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, 22 Jun 2012 07:39: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>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~cmoulliard">charles
Moulliard</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >the same thread. That autorises to
develop applications using Transactions - Tx. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">!camel-direct-vm.png|border=1|width=100px!
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">!camel-direct-vm.png|border=1,width=100px!
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. URI format <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <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>

<p>This component allows also to connect routes deployed in different OSGI Bundles as
you can see here after. Even if they are running in different bundles, the camel routes will
use<br/>
the same thread. That autorises to develop applications using Transactions - Tx.</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/27849601/camel-direct-vm.png?version=1&amp;modificationDate=1340350261506"
width="100px" style="border: 1px solid black" /></span></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/pages/diffpagesbyversion.action?pageId=27849601&revisedVersion=5&originalVersion=4">View
Changes</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