JavaSpace Component
Available as of Camel 2.1
The javaspace component is a transport for working with any JavaSpace compliant implementation and this component has been tested with both the Blitz implementation and the GigaSpace implementation .
This component can be used for sending and receiving any object inheriting from the Jini net.jini.core.entry.Entry
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.
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 BeanExchange
. It can be used to invoke a POJO remotely, using a JavaSpace as a transport.
This latter feature can provide a simple implementation of the master/worker pattern, where a POJO provides the business logic for the worker.
Look at the test cases for examples of various use cases for this component.
Maven users will need to add the following dependency to their pom.xml
for this component:
Code Block | ||||
---|---|---|---|---|
| ||||
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-javaspace</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
|
URI format
Code Block |
---|
javaspace:jini://host[?options] |
You can append query options to the URI in the following format, ?option=value&option=value&...
Options
Div | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||
|
Examples
Sending and Receiving Entries
No Formatcode |
---|
//Sending sending route from("direct:input") .to("javaspace:jini://localhost?spaceName=mySpace"); //Receiving receiving Route from("javaspace:jini://localhost?spaceName=mySpace&templateId=template&verb=take&concurrentConsumers=1") .to("mock:foo"); |
In this case the payload can be any object that inherits from the Jini Entry
type.
...
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:
No Formatcode |
---|
// client side from("direct:input") .to("javaspace:jini://localhost?spaceName=mySpace"); //Client server side from("javaspace:jini://localhost?concurrentConsumers=10&spaceName=mySpace") .to("pojomock:pojofoo"); //Server side |
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.
Options
Name | Default Value | Description |
---|---|---|
| | Specifies the JavaSpace name. |
| | Specifies the verb for getting JavaSpace entries. The values can be: |
| | If |
| | Specifies the transaction timeout. |
| | Specifies the number of concurrent consumers getting entries from the JavaSpace. |
| | If present, this option specifies the Spring bean ID of the template to use for reading/taking entries. |
Using camel-javaspace
To use this module, you need the FUSE Mediation Router distribution. Or you can just add the following dependency to your pom.xml
file, substituting the version number of the latest release:
...
.
...
Make sure that you are pointing at the right Maven repository:
Code Block |
---|
<repository>
<id>fuse</id>
<name>Progress Open Source Community Release Repository</name>
<url>http://repo.fusesource.com/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
|
Building from source
The source for camel-javaspace
is available at: http://fusesource.com/forge/svn/fuseeip/trunk/components/camel-javaspace/
You need to register with http://fusesource.com to be able to access subversion.
The full FUSE distro is available from: http://fusesource.com/products/enterprise-camel/
Include Page | ||||
---|---|---|---|---|
|