RMI

RMI Component

The rmi: component binds PojoExchanges to the RMI protocol (JRMP).

Since this binding is just using RMI, normal RMI rules still apply regarding what methods can be invoked. This component supports only PojoExchanges that carry a method invocation from an interface that extends the Remote interface. All parameters in the method should be either Serializable or Remote objects.

URI format

rmi://rmi-regisitry-host:rmi-registry-port/registry-path[?options]

For example:

rmi://localhost:1099/path/to/service

You can append query options to the URI in this format, ?option=value&option=value&...

Dependencies

Maven users need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-rmi</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

Options

Name Default Description
method null Apache Camel 1.3: You can set the name of the method to invoke.
remoteInterfaces null Apache Camel 2.7: You can set this option in the XML DSL to specify a comma-separated list of interface names.

Using

To call out to an existing RMI service registered in an RMI registry, create a route similar to this:

from("pojo:foo").to("rmi://localhost:1099/foo");

To bind an existing camel processor or service in an RMI registry, define an RMI endpoint like this:

RmiEndpoint endpoint= (RmiEndpoint) endpoint("rmi://localhost:1099/bar");
endpoint.setRemoteInterfaces(ISay.class);
from(endpoint).to("pojo:bar");
[Note]Note

When binding an RMI consumer endpoint, you must specify the Remote interfaces that are exposed.

Apache Camel 2.7 onwards: In XML DSL, you can do thus:

    <camel:route>
        <from uri="rmi://localhost:37541/helloServiceBean?remoteInterfaces=org.apache.camel.example.osgi.HelloService"/>
        <to uri="bean:helloServiceBean"/>
    </camel:route>