<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="rmi"
    xmlns:xlink="http://www.w3.org/1999/xlink">
  <title>RMI Support</title>

  <section id="rmi-intro">
    <title>Introduction</title>
    <para>
    This Chapter explains how to use RMI specific channel adapters to distribute a system over multiple JVMs. The first section will deal with sending messages over RMI. The second section shows how to receive messages over RMI. The last section shows how to define rmi channel adapters through the namespace support.
    </para>
  </section>

  <section id="rmi-outbound">
    <title>Outbound RMI</title>
    <para>
    To send messages from a channel over RMI, simply define an <classname>RmiOutboundGateway</classname>. This gateway will use Spring's RmiProxyFactoryBean internally to create a proxy for a remote gateway. Note that to invoke a remote interface that doesn't use Spring Integration you should use a service activator in combination with Spring's RmiProxyFactoryBean.
  </para>
  <para>
    To configure the outbound gateway write a bean definition like this:
    <programlisting language="xml"><![CDATA[  <bean id="rmiOutGateway" class=org.spf.integration.rmi.RmiOutboundGateway>
    <constructor-arg value="rmi://host"/>
    <property name="replyChannel" value="replies"/>
  </bean>]]>
  </programlisting>
    </para>
  </section>

  <section id="rmi-inbound">
    <title>Inbound RMI</title>
    <para>
    To receive messages over RMI you need to use a <classname>RmiInboundGateway</classname>. This gateway can be configured like this
    <programlisting language="xml"><![CDATA[ <bean id="rmiOutGateway" class=org.spf.integration.rmi.RmiInboundGateway>
     <property name="requestChannel" value="requests"/>
 </bean>]]>
    </programlisting>
    </para>
  </section>

  <section id="rmi-namespace">
    <title>RMI namespace support</title>
    <para>
    To configure the inbound gateway you can choose to use the namespace support for it. The following code snippet shows the different configuration options that are supported.
    <programlisting language="xml"><![CDATA[ <rmi:inbound-gateway id="gatewayWithDefaults" request-channel="testChannel"/>

 <rmi:inbound-gateway id="gatewayWithCustomProperties" request-channel="testChannel"
                      expect-reply="false" request-timeout="123" reply-timeout="456"/>

 <rmi:inbound-gateway id="gatewayWithHost" request-channel="testChannel"
                      registry-host="localhost"/>

 <rmi:inbound-gateway id="gatewayWithPort" request-channel="testChannel"
                      registry-port="1234"/>

 <rmi:inbound-gateway id="gatewayWithExecutorRef" request-channel="testChannel"
                      remote-invocation-executor="invocationExecutor"/>]]></programlisting>
    </para>
    <para>
    To configure the outbound gateway you can use the namespace support as well. The following code snippet shows the different configuration for an outbound rmi gateway.
    <programlisting language="xml"><![CDATA[ <rmi:outbound-gateway id="gateway"
                       request-channel="localChannel"
                       remote-channel="testChannel"
                       host="localhost"/>]]></programlisting>
    </para>
  </section>

</chapter>
