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 Thu, 01 Oct 2009 13:19: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/~davsclaus">Claus
Ibsen</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="JavaSpace-JavaSpaceComponent"></a>JavaSpace Component</h2>
<p><b>Available as of Camel 2.1</b></p>

<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-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=15&originalVersion=14">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