camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Camel > JavaSpace
Date Thu, 01 Oct 2009 13:19:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="">JavaSpace</a></h2>
     <h4>Page <b>edited</b> by             <a href="">Claus
     <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=""
rel="nofollow">Blitz implementation </a> and the <a href=""
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>

<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

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>//Sending route

//Receiving Route

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

<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
<pre>from("direct:input").to("javaspace:jini://localhost?spaceName=mySpace"); //Client

//Server side

<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>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
<td class='confluenceTd'> <tt>spaceName</tt>  </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Specifies the JavaSpace name. </td>
<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>
<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>
<td class='confluenceTd'> <tt>transactionalTimeout</tt>  </td>
<td class='confluenceTd'> <tt>Long.MAX_VALUE</tt> </td>
<td class='confluenceTd'> Specifies the transaction timeout.  </td>
<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>
<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>

<h3><a name="JavaSpace-SeeAlso"></a>See Also</h3>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
	<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

     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>

       <a href="">View Online</a>
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message