3.3 RMI Adapters

The RmiSourceAdapter is built upon Spring's RmiServiceExporter. However, since it is adapting a MessageChannel, there is no need to specify the serviceInterface. Likewise, the serviceName is automatically generated based on the channel name. Therefore, creating the adapter is as simple as providing a reference to its channel:

RmiSourceAdapter rmiSourceAdapter = new RmiSourceAdapter(channel);

The RmiTargetAdapter encapsulates the creation of a proxy that is capable of communicating with an RmiSourceAdapter running in another process. Since the interface is already known, the only required information is the URL. The URL should include the host, port (default is '1099'), and 'serviceName'. The 'serviceName' must match that created by the RmiSourceAdapter (the prefix is available as a constant).

String url = "http://somehost:1099/" + RmiSourceAdapter.SERVICE_NAME_PREFIX + "someChannel";
RmiTargetAdapter rmiTargetAdapter = new RmiTargetAdapter(url);