camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > VM
Date Sun, 17 Jul 2011 13:45: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/VM">VM</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~muellerc">Christian
Mueller</a>
    </h4>
        <br/>
                         <h4>Changes (1)</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" >You can append query options to the
URI in the following format, {{?option=value&amp;option=value&amp;...}} <br>
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{info:title=Camel
1.x to 2.3 - Same URI must be used for both producer and consumer} <br>An exactly identical
[VM] endpoint URI *must* be used for both the producer endpoint and the consumer endpoint.
Otherwise Camel will create a second [VM] endpoint, even thought the {{someName}} portion
of the URI is identical. For example: <br>{code} <br>from(&quot;direct:foo&quot;).to(&quot;vm:bar?concurrentConsumers=5&quot;);
<br> <br>from(&quot;vm:bar?concurrentConsumers=5&quot;).to(&quot;file://output&quot;);
<br>{code} <br>Notice that we have to use the full URI including options in both
the producer and consumer. <br> <br>In Camel 2.4 this has been fixed so its the
queue name that must match, eg in this example we are using bar as the queue name. <br>{info}
<br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. Options <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="VM-VMComponent"></a>VM Component</h2>

<p>The <b>vm:</b> component provides asynchronous <a href="http://www.eecs.harvard.edu/~mdw/proj/seda/"
class="external-link" rel="nofollow">SEDA</a> behavior so that messages are exchanged
on a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html"
class="external-link" rel="nofollow">BlockingQueue</a> and consumers are invoked
in a separate thread pool to the producer.</p>

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

<p>This component is an extension to the <a href="/confluence/display/CAMEL/SEDA"
title="SEDA">SEDA</a> component.</p>

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

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

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint
within the JVM (or at least within the classloader which loaded the camel-core.jar)</p>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Camel 1.x
to 2.3 - Same URI must be used for both producer and consumer</b><br />An exactly
identical <a href="/confluence/display/CAMEL/VM" title="VM">VM</a> endpoint URI
<b>must</b> be used for both the producer endpoint and the consumer endpoint.
Otherwise Camel will create a second <a href="/confluence/display/CAMEL/VM" title="VM">VM</a>
endpoint, even thought the <tt>someName</tt> portion of the URI is identical.
For example:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:foo"</span>).to(<span class="code-quote">"vm:bar?concurrentConsumers=5"</span>);

from(<span class="code-quote">"vm:bar?concurrentConsumers=5"</span>).to(<span
class="code-quote">"file:<span class="code-comment">//output"</span>);</span>
</pre>
</div></div>
<p>Notice that we have to use the full URI including options in both the producer and
consumer.</p>

<p>In Camel 2.4 this has been fixed so its the queue name that must match, eg in this
example we are using bar as the queue name.</p></td></tr></table></div>

<h3><a name="VM-Options"></a>Options</h3>

<p>See the <a href="/confluence/display/CAMEL/SEDA" title="SEDA">SEDA</a>
component for options and other important usage as the same rules applies for this <a href="/confluence/display/CAMEL/VM"
title="VM">VM</a> component.</p>

<h3><a name="VM-Samples"></a>Samples</h3>
<p>In the route below we send the exchange to the VM queue that is working across CamelContext
instances:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:in"</span>).bean(MyOrderBean.class).to(<span
class="code-quote">"vm:order.email"</span>);
</pre>
</div></div>

<p>And then in another Camel context such as deployed as in another <tt>.war</tt>
application:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"vm:order.email"</span>).bean(MyOrderEmailSender.class);
</pre>
</div></div>

<h3><a name="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/SEDA" title="SEDA">SEDA</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/VM">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=60691&revisedVersion=11&originalVersion=10">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/VM?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message