[rabbitmq-discuss] java client library rpc client
Matthias Radestock
matthias at rabbitmq.com
Fri Apr 23 09:08:44 BST 2010
Rajesh,
Reddy, Rajesh (GPT EMEA) wrote:
> Basically my process makes an rpccall and gets reply from one or more
> other process. This works if the rpcclient receives one reply for its
> request, but as soon as it gets multiple replies it fails. I get the
> following exception which doesn't say much about the root cause.
The rpc abstractions that ship with the RabbitMQ clients are not
designed to handle multiple replies.
> This is possible in .NET library of rabbitmq and working fine.
The difference between the Java and .net version is that the former
processes replies eagerly, i.e. any message received from the rpc
client's reply queue is processed immediately, whereas the .net version
processes replies lazily, i.e. only when an rpc caller is waiting for a
result. If you tried re-using the same .net SimpleRpcClient instance for
another call things would break in much the same way as for the Java
client since the code would find a reply that is not correlated to the
current request.
To implement the "wait for first reply and discard all others" pattern
properly I suggest you amend the rpc client code with an "unexpected
reply" handler/callback that by default throws an exception (thus
mimicking the current behaviour). In your application code you could
then set that handler to ignore unexpected replies instead.
Patches are welcome.
Regards,
Matthias.
More information about the rabbitmq-discuss
mailing list