camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > JBI
Date Fri, 07 Sep 2012 17:19: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/JBI">JBI</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~muellerc">Christian
Mueller</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Removed the deprecated Camel 1.x documentations<br />
    </div>
        <br/>
                         <h4>Changes (3)</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" >{code} <br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">From
*Camel 1.5* onwards, the</span> <span class="diff-added-words"style="background-color:
#dfd;">The</span> stream caching is default enabled, so it is not necessary to set
the {{streamCaching()}} option. <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">In
*Camel 2.0* we</span> <span class="diff-added-words"style="background-color: #dfd;">We</span>
store big input streams (by default, over 64K) in a {{temp}} file using {{CachedOutputStream}}.
When you close the input stream, the temp file will be deleted. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. Creating a JBI Service
Unit <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>  &lt;properties&gt;
<br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">&lt;camel-version&gt;1.0.0&lt;/camel-version&gt;</span>
<span class="diff-added-words"style="background-color: #dfd;">&lt;camel-version&gt;x.x.x&lt;/camel-version&gt;</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >    &lt;servicemix-version&gt;3.3&lt;/servicemix-version&gt;
<br>  &lt;/properties&gt; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="JBI-JBIComponent"></a>JBI Component</h2>

<p>The <b>jbi</b> component is implemented by the <a href="http://servicemix.apache.org/servicemix-camel.html"
class="external-link" rel="nofollow">ServiceMix Camel module</a> and provides integration
with a JBI Normalized Message Router, such as the one provided by <a href="http://servicemix.apache.org/"
class="external-link" rel="nofollow">Apache ServiceMix</a>.</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>See below for information
about how to use <tt>StreamSource</tt> types from <a href="http://servicemix.apache.org/"
class="external-link" rel="nofollow">ServiceMix</a> in Camel.</td></tr></table></div>

<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">"jbi:endpoint:http:<span class="code-comment">//foo.bar.org/MyService/MyEndpoint"</span>)</span>
</pre>
</div></div>

<p>Automatically exposes a new endpoint to the bus, where the service QName is {<tt><a
href="http://foo.bar.org" class="external-link" rel="nofollow">http://foo.bar.org</a>}MyService</tt>
and the endpoint name is <tt>MyEndpoint</tt> (see <a href="#JBI-URIformat">URI&#45;format</a>).</p>

<p>When a JBI 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">"jbi:endpoint:http:<span class="code-comment">//foo.bar.org/MyService/MyEndpoint"</span>)</span>
</pre>
</div></div>

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

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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
jbi:service:serviceNamespace[sep]serviceName[?options]
jbi:endpoint:serviceNamespace[sep]serviceName[sep]endpointName[?options]
jbi:name:endpointName[?options]
</pre>
</div></div>

<p>The separator that should be used in the endpoint URL is:</p>
<ul>
	<li><tt>/</tt> (forward slash), if <tt>serviceNamespace</tt>
starts with <tt>http://</tt>, or</li>
	<li><tt>:</tt> (colon), if <tt>serviceNamespace</tt> starts
with <tt>urn:foo:bar</tt>.</li>
</ul>


<p>For more details of valid JBI URIs see the <a href="http://servicemix.apache.org/uris.html"
class="external-link" rel="nofollow">ServiceMix URI Guide</a>. </p>

<p>Using the <tt>jbi:service:</tt> or <tt>jbi:endpoint:</tt>
URI formats sets the service QName on the JBI endpoint to the one specified. Otherwise, the
default Camel JBI Service QName is used, which is:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
{http:<span class="code-comment">//activemq.apache.org/camel/schema/jbi}endpoint</span>
</pre>
</div></div>

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

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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
jbi:service:http:<span class="code-comment">//foo.bar.org/MyService
</span>jbi:endpoint:urn:foo:bar:MyService:MyEndpoint
jbi:endpoint:http:<span class="code-comment">//foo.bar.org/MyService/MyEndpoint
</span>jbi:name:cheese
</pre>
</div></div>

<h3><a name="JBI-URIoptions"></a>URI options</h3>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>mep</tt> </td>
<td class='confluenceTd'> MEP of the Camel Exchange </td>
<td class='confluenceTd'> Allows users to override the MEP set on the Exchange object.
Valid values for this option are <tt>in-only</tt>, <tt>in-out</tt>,
<tt>robust-in-out</tt> and <tt>in-optional-out</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>operation</tt> </td>
<td class='confluenceTd'> Value of the <tt>jbi.operation</tt> header property
</td>
<td class='confluenceTd'> Specifies the JBI operation for the <tt>MessageExchange</tt>.
 If no value is supplied, the JBI binding will use the value of the <tt>jbi.operation</tt>
header property. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>serialization</tt> </td>
<td class='confluenceTd'> <tt>basic</tt> </td>
<td class='confluenceTd'> Default value (<tt>basic</tt>) will check if headers
are serializable by looking at the type, setting this option to <tt>strict</tt>
will detect objects that can not be serialized although they implement the <tt>Serializable</tt>
interface.  Set to <tt>nocheck</tt> to disable this check altogether, note that
this should only be used for in-memory transports like SEDAFlow, otherwise you can expect
to get <tt>NotSerializableException</tt> thrown at runtime. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>convertException</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <tt>false</tt>: send any exceptions thrown from
the Camel route back unmodified <br class="atl-forced-newline" /> <tt>true</tt>:
convert all exceptions to a JBI FaultException (can be used to avoid non-serializable exceptions
or to implement generic error handling </td>
</tr>
</tbody></table>
</div>


<h4><a name="JBI-Examples"></a>Examples</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
jbi:service:http:<span class="code-comment">//foo.bar.org/MyService?mep=in-out     
 (override the MEP, use InOut JBI MessageExchanges)
</span>jbi:endpoint:urn:foo:bar:MyService:MyEndpoint?mep=in      (override the MEP,
use InOnly JBI MessageExchanges)  
jbi:endpoint:urn:foo:bar:MyService:MyEndpoint?operation={http:<span class="code-comment">//www.mycompany.org}AddNumbers

</span> (overide the operation <span class="code-keyword">for</span> the
JBI Exchange to {http:<span class="code-comment">//www.mycompany.org}AddNumbers)</span>
</pre>
</div></div>

<h3><a name="JBI-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">"jbi:endpoint:http:<span class="code-comment">//foo.bar.org/MyService/MyEndpoint"</span>).streamCaching().to(<span
class="code-quote">"xslt:transform.xsl"</span>, <span class="code-quote">"bean:doSomething"</span>);</span>
</pre>
</div></div>

<p>The stream caching is default enabled, so it is not necessary to set the <tt>streamCaching()</tt>
option.<br/>
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="JBI-CreatingaJBIServiceUnit"></a>Creating a JBI Service Unit</h3>

<p>If you have some Camel routes that you want to deploy inside JBI as a Service Unit,
you can use the <a href="/confluence/display/CAMEL/JBI+Service+Unit+Archetype" title="JBI
Service Unit Archetype">JBI Service Unit Archetype</a> to create a new Maven project
for the Service Unit.</p>

<p>If you have an existing Maven project that you need to convert into a JBI Service
Unit, you may want to consult <a href="http://servicemix.apache.org/maven-jbi-plugin.html"
class="external-link" rel="nofollow">ServiceMix Maven JBI Plugins</a> for further
help. The key steps are as follows:</p>

<ul>
	<li>Create a Spring XML file at <tt>src/main/resources/camel-context.xml</tt>
to bootstrap your routes inside the JBI Service Unit.</li>
	<li>Change the POM file's packaging to <tt>jbi-service-unit</tt>.</li>
</ul>


<p>Your <tt>pom.xml</tt> should look something like this to enable the <tt>jbi-service-unit</tt>
packaging: </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;project xmlns=<span class="code-quote">"http:<span class="code-comment">//maven.apache.org/POM/4.0.0"</span>
xmlns:xsi=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
</span>         xsi:schemaLocation=<span class="code-quote">"http:<span class="code-comment">//maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"</span>&gt;
</span>
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

  &lt;groupId&gt;myGroupId&lt;/groupId&gt;
  &lt;artifactId&gt;myArtifactId&lt;/artifactId&gt;
  &lt;packaging&gt;jbi-service-unit&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;

  &lt;name&gt;A Camel based JBI Service Unit&lt;/name&gt;

  &lt;url&gt;http:<span class="code-comment">//www.myorganization.org&lt;/url&gt;
</span>
  &lt;properties&gt;
    &lt;camel-version&gt;x.x.x&lt;/camel-version&gt;
    &lt;servicemix-version&gt;3.3&lt;/servicemix-version&gt;
  &lt;/properties&gt;

  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.servicemix&lt;/groupId&gt;
      &lt;artifactId&gt;servicemix-camel&lt;/artifactId&gt;
      &lt;version&gt;${servicemix-version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.servicemix&lt;/groupId&gt;
      &lt;artifactId&gt;servicemix-core&lt;/artifactId&gt;
      &lt;version&gt;${servicemix-version}&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;build&gt;
    &lt;defaultGoal&gt;install&lt;/defaultGoal&gt;

    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;source&gt;1.5&lt;/source&gt;
          &lt;target&gt;1.5&lt;/target&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;

      &lt;!-- creates the JBI deployment unit --&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.servicemix.tooling&lt;/groupId&gt;
        &lt;artifactId&gt;jbi-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;${servicemix-version}&lt;/version&gt;
        &lt;extensions&gt;<span class="code-keyword">true</span>&lt;/extensions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;
</pre>
</div></div>


<h3><a name="JBI-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>
	<li><a href="http://servicemix.apache.org/servicemix-camel.html" class="external-link"
rel="nofollow">ServiceMix Camel module</a></li>
	<li><a href="http://servicemix.apache.org/3-beginner-using-apache-camel-inside-servicemix.html"
class="external-link" rel="nofollow">Using Camel with ServiceMix</a></li>
	<li><a href="http://servicemix.apache.org/order-file-processing.html" class="external-link"
rel="nofollow">Cookbook on using Camel with ServiceMix</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/JBI">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=52095&revisedVersion=29&originalVersion=28">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/JBI?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message