Results 1 to 4 of 4

Thread: Question about Rmi-handler

  1. #1
    Join Date
    Aug 2008
    Location
    Paris
    Posts
    2

    Question Question about Rmi-handler

    Hello,

    I practice SI starting from the "cafe" exemple. Like Alca (thread titled "Remoting version of CafeDemo") I 'd like to use RMI. Everything has worked fine until I added a return value from the Barista (server) to the client (Cafe). In the case the client get the following Exception :

    Code:
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:  	java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.springframework.integration.message.MessageExchangeTemplate$TemporaryReturnAddress
    I know that the command goes well to the server because the service-activator (a method in a bean) is executed

    Indeed the TemporaryReturnAddress inner class is not serializable but I feel that the problem comes from my work.

    Here the client config :

    Code:
    <integration:message-bus />
    <integration:channel id="orders" />
    <integration:channel id="drinks" />
    
    <integration:channel id="returnChannel">
    </integration:channel>
    <integration:channel id="coldDrinks">
    </integration:channel>
    <integration:channel id="hotDrinks" />
    <integration:rmi-handler id="rmiTargetColdDrinks" remote-channel="coldDrinks" host="localhost" port="1099" />
    <integration:rmi-handler id="rmiTargetHotDrinks"remote-channel="hotDrinks" host="localhost" port="1099" />
    
    <bean id="drinkRouter"		class="org.springframework.integration.samples.cafe.DrinkRouter" />
    <integration:router input-channel="drinks" ref="drinkRouter"
    	method="resolveDrinkChannel" />
    <bean id="orderSplitter"
    	class="org.springframework.integration.samples.cafe.OrderSplitter" />
    <integration:splitter input-channel="orders" output-channel="drinks"
    	ref="orderSplitter" method="split" />
    
    <integration:service-activator input-channel="returnChannel" ref="clientRmiInter"	method="coldDrinkscb">
    </integration:service-activator>
    <integration:service-activator input-channel="coldDrinks" ref="rmiTargetColdDrinks">
    </integration:service-activator>
    <integration:service-activator input-channel="hotDrinks" ref="rmiTargetHotDrinks" />
    
    <bean id="clientRmiInter"	class="org.springframework.integration.samples.cafe.ClientRmiInterceptor" />
    <bean id="clientInter"
    	class="org.springframework.integration.samples.cafe.ClientChannelInterceptor" />
    
    <bean id="cafe"	class="org.springframework.integration.samples.cafe.Cafe">
    <property name="orderChannel" ref="coldDrinks" />
    </bean>
    (ps: I deactivate the router / spliiter / all interceptors)
    (I tried to add an output-channel to coldDrinks service-activator->same behaviour).


    Does anyone has an idea that helps ?

    Thanks.

    P.Herve

  2. #2
    Join Date
    Aug 2008
    Location
    Paris
    Posts
    2

    Default Question about Rmi-handler : New info

    Hello,

    I am still fighting againt my problem

    As far as I understand the problem the exception comes from the server. Indeed, the SI method MessageExchangeTemplate.sendAndReceive creates a response message including a return address in the header. This field is filled with a TemporaryReturnAddress object. Then this message goes to the RMI gateway. The problem is that the TemporaryReturnAddress CAN NOT be send by RMI because this class is not serializable.

    Is anyone succeed in using RMI-GATEWAY with a method that has a reply ???

    Thanks.

    P.Herve

  3. #3
    Join Date
    Nov 2008
    Posts
    1

    Default rmi adapter with reply

    Hi,

    I've met this question also, and I don't know how to configure the reply channel correctly. Here is my configure:

    1) client
    <message-bus />

    <channel id="input" />

    <service-activator input-channel="input" ref="rmiHandler" />

    <rmi-handler id="rmiHandler" remote-channel="input" host="localhost" />

    <channel-adapter id="replyChannel" target="console" />
    <console-target id="console" />

    2) server
    <message-bus />
    <annotation-driven />

    <context:component-scan base-package="mypackage.rmi"/>

    <channel id="input" />
    <channel id="output" />

    <service-activator input-channel="input" ref="rmiHello"
    method="sayHello" output-channel="replyChannel"/>

    <rmi-gateway id="rmiSource" request-channel="input" reply-channel="output" />

    <channel-adapter id="replyChannel" target="console" />
    <console-target id="console" />

    <beans:bean name="rmiHello" class="mypackage.rmi.HelloRemote" />

    </beans:beans>

    3) mypackge.rmi.HelloRemote
    public class HelloRemote {
    private int i = 0;
    public String sayHello(String msg) throws RemoteException {
    i++;
    System.out.println("receive remote call:" + i);

    return "Hello " + msg;
    }
    }

    In server console, i could see sayHello has been called; but I can't see
    the return message in client cosole.

    I think we need a more detail demo or test example in si docs.

  4. #4
    Join Date
    Oct 2007
    Location
    Toronto, ON
    Posts
    90

    Default

    Hi,

    From the configuration, it looks like you are using M6 or earlier. Try switching to RC1 and use the <rmi:*> namespace. If you still encounter issues, let us know.
    Marius Bogoevici,
    Spring Integration Committer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •