Unexpected error with client cluster using single reply queue #2538
-
I am using single reply-to channel with spring rabbitmq to perform RPC. On the client side, everything is fine with basic tests. When duplicating the clients (setting clients up as a cluster), I am getting the following error:
I looked at RabbitTemplate and I understand why I am getting this error. Some details: In RabbitTemplate, this code makes the error occur.
As I understand it, RabbitTemplate is looking with the given messageTag inside a Map where he stores the replies he is waiting for. But in my case, Client B is not waiting for this reply. Since it is Client A. So getting the unexpected error and dont know how to manage my usecase. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
When using named reply queues, each application instance needs to use its own reply queue; rather than using named queues, it is generally easier to use direct reply-to, where the broker configures a pseudo reply queue for each channel. https://docs.spring.io/spring-amqp/docs/current/reference/html/#direct-reply-to |
Beta Was this translation helpful? Give feedback.
-
I undestand how it would/could work but I really need one reply queue. To simplify: this reply queue is monitored and when under load (and other checks), other clients are started. As I understand it, it is not possible with Spring RabbitMQ. |
Beta Was this translation helpful? Give feedback.
That is correct; each instance needs its own reply queue; otherwise you would have multiple competing consumers on the single queue, with no guarantees that the reply will go to the request originator.
This has not a limitation of the Spring project; it's how RabbitMQ works; rejecting the message would not necessarily mean that it will be delivered to the other instance.