camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > NMR
Date Mon, 16 May 2011 09:36: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/NMR">NMR</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~gertvanthienen">Gert
Vanthienen</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" >{div:class=confluenceTableSmall} <br>||
Option || Default Value || Description || <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{runAsSubject}} | {{false}} | When this is set to *{{true}}* on a consumer endpoint, the
endpoint will be invoked on behalf of the {{Subject}} that is set on the {{Exchange}} (i.e.
the call to {{Subject.getSubject(AccessControlContext)}} will return the {{Subject}} instance)
| <br></td></tr>
            <tr><td class="diff-unchanged" >| {{synchronous}} | {{false}} | When
this is set to *{{true}}* on a consumer endpoint, an incoming, synchronous NMR Exchange will
be handled on the sender&#39;s thread instead of being handled on a new thread of the
NMR endpoint&#39;s thread pool | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{timeout}} | {{0}} | When this is set to a value greater than 0, the producer endpoint will
timeout if it doesn&#39;t receive a response from the NMR within the given timeout period
(in milliseconds).  Configuring a timeout value will switch to using synchronous interactions
with the NMR instead of the usual asynchronous messaging. | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="NMR-NMRComponent"></a>NMR Component</h2>

<p>The <b>nmr</b> component is an adapter to the Normalized Message Router
(NMR) in <a href="http://servicemix.apache.org/home.html" class="external-link" rel="nofollow">ServiceMix</a>,
which is intended for use by Camel applications deployed directly into the OSGi container.
By contrast, the <a href="/confluence/display/CAMEL/JBI" title="JBI">JBI</a> component
is intended for use by Camel applications deployed into the ServiceMix JBI container.</p>

<h3><a name="NMR-Installing"></a>Installing</h3>

<p>The NMR component is provided with Apache ServiceMix. It is <b>not</b>
distributed with Camel. To install the NMR component in ServiceMix, enter the following command
in the ServiceMix console window:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
features install nmr
</pre>
</div></div>

<p>You also need to instantiate the NMR component. You can do this by editing your Spring
configuration file, <tt>META-INF/spring/*.xml</tt>, and adding the following <tt>bean</tt>
instance:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;beans <span class="code-keyword">xmlns:osgi</span>=<span
class="code-quote">"http://www.springframework.org/schema/osgi"</span> ... &gt;</span>
    ...
    <span class="code-tag">&lt;bean id=<span class="code-quote">"nmr"</span>
class=<span class="code-quote">"org.apache.servicemix.camel.nmr.ServiceMixComponent"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"nmr"</span>&gt;</span>
            <span class="code-tag">&lt;osgi:reference interface=<span class="code-quote">"org.apache.servicemix.nmr.api.NMR"</span>
/&gt;</span>
        <span class="code-tag">&lt;/property&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    ...
<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div>

<h3><a name="NMR-NMRconsumerandproducerendpoints"></a>NMR consumer and producer
endpoints</h3>

<p>The following code:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"nmr:MyServiceEndpoint"</span>)
</pre>
</div></div>

<p>Automatically exposes a new endpoint to the bus with endpoint name <tt>MyServiceEndpoint</tt>
(see <a href="#NMR-URIformat">URI&#45;format</a>).</p>

<p>When an NMR endpoint appears at the end of a route, for example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
to(<span class="code-quote">"nmr:MyServiceEndpoint"</span>)
</pre>
</div></div>

<p>The messages sent by this producer endpoint are sent to the already deployed JBI
endpoint.</p>

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

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

<h4><a name="NMR-URIOptions"></a>URI Options</h4>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>runAsSubject</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> When this is set to <b><tt>true</tt></b>
on a consumer endpoint, the endpoint will be invoked on behalf of the <tt>Subject</tt>
that is set on the <tt>Exchange</tt> (i.e. the call to <tt>Subject.getSubject(AccessControlContext)</tt>
will return the <tt>Subject</tt> instance) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>synchronous</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> When this is set to <b><tt>true</tt></b>
on a consumer endpoint, an incoming, synchronous NMR Exchange will be handled on the sender's
thread instead of being handled on a new thread of the NMR endpoint's thread pool </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>timeout</tt> </td>
<td class='confluenceTd'> <tt>0</tt> </td>
<td class='confluenceTd'> When this is set to a value greater than 0, the producer endpoint
will timeout if it doesn't receive a response from the NMR within the given timeout period
(in milliseconds).  Configuring a timeout value will switch to using synchronous interactions
with the NMR instead of the usual asynchronous messaging. </td>
</tr>
</tbody></table>
</div>
</div>

<h4><a name="NMR-Examples"></a>Examples</h4>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"nmr:MyServiceEndpoint"</span>)
from(<span class="code-quote">"nmr:MyServiceEndpoint?synchronous=<span class="code-keyword">true</span>"</span>).to(<span
class="code-quote">"nmr:AnotherEndpoint"</span>)
</pre>
</div></div>

<h3><a name="NMR-UsingStreambodies"></a>Using Stream bodies</h3>
<p>If you are using a stream type as the message body, you should be aware that a stream
is only capable of being read once. So if you enable <tt>DEBUG</tt> logging, the
body is usually logged and thus read. To deal with this, Camel has a <tt>streamCaching</tt>
option that can cache the stream, enabling you to read it multiple times.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"nmr:MyEndpoint"</span>).streamCaching().to(<span
class="code-quote">"xslt:transform.xsl"</span>, <span class="code-quote">"bean:doSomething"</span>);
</pre>
</div></div>

<p>From <b>Camel 1.5</b> onwards, the stream caching is default enabled,
so it is not necessary to set the <tt>streamCaching()</tt> option.<br/>
In <b>Camel 2.0</b> we store big input streams (by default, over 64K) in a <tt>temp</tt>
file using <tt>CachedOutputStream</tt>. When you close the input stream, the temp
file will be deleted.</p>

<h3><a name="NMR-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>

    </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/NMR">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=3473729&revisedVersion=5&originalVersion=4">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/NMR?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message