PDA

View Full Version : Question about Rmi-handler



paherve
Aug 29th, 2008, 07:49 AM
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 :


java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.springframework.integration.message.MessageExc hangeTemplate$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 :



<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.Drink Router" />
<integration:router input-channel="drinks" ref="drinkRouter"
method="resolveDrinkChannel" />
<bean id="orderSplitter"
class="org.springframework.integration.samples.cafe.Order Splitter" />
<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.Clien tRmiInterceptor" />
<bean id="clientInter"
class="org.springframework.integration.samples.cafe.Clien tChannelInterceptor" />

<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

paherve
Sep 3rd, 2008, 10:07 AM
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

chonglu yin
Nov 6th, 2008, 09:24 PM
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.

mbogoevici
Nov 7th, 2008, 12:58 AM
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.