camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > JavaSpace
Date Fri, 11 Sep 2009 16:26:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/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/JavaSpace">JavaSpace</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~fbolton">Fintan
Bolton</a>
    </h4>
     Copy edits and updated Fuse Maven details
          <div id="versionComment" class="noteMacro" style="display:none; padding: 5px;">
     Copy edits and updated Fuse Maven details<br />
     </div>
          <br/>
     <div class="notificationGreySide">
         <h2><a name="JavaSpace-JavaSpaceComponent"></a>JavaSpace Component</h2>

<p>The <b>javaspace</b> component is a transport for working with any JavaSpace
compliant implementation and this component has been tested with both the <a href="http://www.dancres.org/blitz/"
rel="nofollow">Blitz implementation </a> and the <a href="http://www.gigaspaces.com/"
rel="nofollow">GigaSpace implementation </a>.<br/>
This component can be used for sending and receiving any object inheriting from the Jini <tt>net.jini.core.entry.Entry</tt>
class. It is also possible to pass the bean ID of a template that can be used for reading/taking
the entries from the space.<br/>
This component can be used for sending/receiving any serializable object acting as a sort
of generic transport. The JavaSpace component contains a special optimization for dealing
with the <tt>BeanExchange</tt>. It can be used to invoke a POJO remotely, using
a JavaSpace as a transport.<br/>
This latter feature can provide a simple implementation of the master/worker pattern, where
a POJO provides the business logic for the worker.<br/>
Look at the test cases for examples of various use cases for this component.</p>

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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
javaspace:jini:<span class="code-comment">//host[?options]</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>

<h3><a name="JavaSpace-Examples"></a>Examples</h3>

<h4><a name="JavaSpace-SendingandReceivingEntries"></a>Sending and Receiving
Entries</h4>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>//Sending route
from("direct:input").to("javaspace:jini://localhost?spaceName=mySpace");

//Receiving Route
from("javaspace:jini://localhost?spaceName=mySpace&amp;templateId=template&amp;verb=take&amp;concurrentConsumers=1")
</pre>
</div></div>

<p>In this case the payload can be any object that inherits from the Jini <tt>Entry</tt>
type.</p>

<h4><a name="JavaSpace-Sendingandreceivingserializableobjects"></a>Sending
and receiving serializable objects</h4>
<p>Using the preceding routes, it is also possible to send and receive any serializable
object. The JavaSpace component detects that the payload is not a Jini <tt>Entry</tt>
and then it automatically wraps the payload with a Camel Jini <tt>Entry</tt>.
In this way, a JavaSpace can be used as a generic transport mechanism.</p>

<h4><a name="JavaSpace-UsingJavaSpaceasaremoteinvocationtransport"></a>Using
JavaSpace as a remote invocation transport</h4>
<p>The JavaSpace component has been tailored to work in combination with the Camel bean
component. It is therefore possible to call a remote POJO using JavaSpace as the transport:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>from("direct:input").to("javaspace:jini://localhost?spaceName=mySpace"); //Client
side

from("javaspace:jini://localhost?concurrentConsumers=10&amp;spaceName=mySpace").to("pojo:pojo");
//Server side
</pre>
</div></div>

<p>In the code there are two test cases showing how to use a POJO to realize the master/worker
pattern. The idea is to use the POJO to provide the business logic and rely on Camel for sending/receiving
requests/replies with the proper correlation.  </p>

<h3><a name="JavaSpace-Options"></a>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>spaceName</tt>  </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Specifies the JavaSpace name. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>verb</tt>  </td>
<td class='confluenceTd'> <tt>take</tt> </td>
<td class='confluenceTd'> Specifies the verb for getting JavaSpace entries. The values
can be: <tt>take</tt> or <tt>read</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transactional</tt>  </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If <tt>true</tt>, sending and receiving entries
is performed within a transaction. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transactionalTimeout</tt>  </td>
<td class='confluenceTd'> <tt>Long.MAX_VALUE</tt> </td>
<td class='confluenceTd'> Specifies the transaction timeout.  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>concurrentConsumers</tt>  </td>
<td class='confluenceTd'> <tt>1</tt> </td>
<td class='confluenceTd'> Specifies the number of concurrent consumers getting entries
from the JavaSpace. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>templateId</tt>  </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> If present, this option specifies the Spring bean ID of the
template to use for reading/taking entries. </td>
</tr>
</tbody></table>


<h3><a name="JavaSpace-Usingcameljavaspace"></a>Using camel-javaspace</h3>

<p>To use this module, you need the <a href="http://open.iona.com/products/fuse-mediation-router/"
rel="nofollow">FUSE Mediation Router</a> distribution. Or you can just add the following
dependency to your <tt>pom.xml</tt> file, substituting the version number of the
latest release:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
  &lt;artifactId&gt;camel-parent&lt;/artifactId&gt;
  &lt;version&gt;1.6.1.2-fuse&lt;/version&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<p>Make sure that you are pointing at the right Maven repository:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
   &lt;repository&gt;
     &lt;id&gt;fuse&lt;/id&gt;
     &lt;name&gt;Progress Open Source Community Release Repository&lt;/name&gt;
     &lt;url&gt;http:<span class="code-comment">//repo.fusesource.com/maven2&lt;/url&gt;
</span>     &lt;snapshots&gt;
       &lt;enabled&gt;<span class="code-keyword">false</span>&lt;/enabled&gt;
     &lt;/snapshots&gt;
     &lt;releases&gt;
       &lt;enabled&gt;<span class="code-keyword">true</span>&lt;/enabled&gt;
     &lt;/releases&gt;
   &lt;/repository&gt;
</pre>
</div></div>

<h3><a name="JavaSpace-Buildingfromsource"></a>Building from source</h3>

<p>The source for <tt>camel-javaspace</tt> is available at: <a href="http://fusesource.com/forge/svn/fuseeip/trunk/components/camel-javaspace/"
rel="nofollow">http://fusesource.com/forge/svn/fuseeip/trunk/components/camel-javaspace/</a></p>

<p>You need to register with <a href="http://fusesource.com" rel="nofollow">http://fusesource.com</a>
to be able to access subversion.</p>

<p>The full FUSE distro is available from: <a href="http://fusesource.com/products/enterprise-camel/"
rel="nofollow">http://fusesource.com/products/enterprise-camel/</a></p>
<h3><a name="JavaSpace-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="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/JavaSpace">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=88712&revisedVersion=14&originalVersion=13">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/JavaSpace?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message