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, 16 Apr 2010 17:49:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1520/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/JBI">JBI</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~slewis">Stan
Lewis</a>
    </h4>
     
          <br/>
     <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"
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/" 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><p>See below
for information about how to use <tt>StreamSource</tt> types from <a href="http://servicemix.apache.org/"
rel="nofollow">ServiceMix</a> in Camel.</p></td></tr></table></div>

<p>The following code:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
from("jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint")
]]></script>
</div></div>

<p>Automatically exposes a new endpoint to the bus, where the service QName is {<tt><a
href="http://foo.bar.org" 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">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
to("jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint")
]]></script>
</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">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
jbi:service:serviceNamespace[sep]serviceName[?options]
jbi:endpoint:serviceNamespace[sep]serviceName[sep]endpointName[?options]
jbi:name:endpointName[?options]
]]></script>
</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"
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">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
{http://activemq.apache.org/camel/schema/jbi}endpoint
]]></script>
</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">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
jbi:service:http://foo.bar.org/MyService
jbi:endpoint:urn:foo:bar:MyService:MyEndpoint
jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint
jbi:name:cheese
]]></script>
</div></div>

<h3><a name="JBI-URIoptions"></a>URI options</h3>
<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 see {{NotSerializableException}}s. </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 clear="all" /> <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>

<h4><a name="JBI-Examples"></a>Examples</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
jbi:service:http://foo.bar.org/MyService?mep=in-out       (override the MEP, use InOut JBI
MessageExchanges)
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://www.mycompany.org}AddNumbers

 (overide the operation for the JBI Exchange to {http://www.mycompany.org}AddNumbers)
]]></script>
</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">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
from("jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint").streamCaching().to("xslt:transform.xsl",
"bean:doSomething");
]]></script>
</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="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"
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">
<script type="syntaxhighlighter" class="toolbar: false; theme: default; brush: java; gutter:
false"><![CDATA[
&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;

  &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://www.myorganization.org&lt;/url&gt;

  &lt;properties&gt;
    &lt;camel-version&gt;1.0.0&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;true&lt;/extensions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;
]]></script>
</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" rel="nofollow">ServiceMix
Camel module</a></li>
	<li><a href="http://servicemix.apache.org/3-beginner-using-apache-camel-inside-servicemix.html"
rel="nofollow">Using Camel with ServiceMix</a></li>
	<li><a href="http://servicemix.apache.org/order-file-processing.html" 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="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/JBI">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=52095&revisedVersion=27&originalVersion=26">View
Change</a>
              |
       <a href="http://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