Description
Describe the bug
RpcClient
must be given a Channel upon construction and if used in mandatory-mode, the constructor adds a ReturnListener
to this channel. However, this listener is never removed. It should be removed in the close
-method.
Reproduction steps
- Instantiate
RpcClient
in mandatory-mode. - Publish an unrouteable RPC message with the client and catch the
UnrouteableRpcRequestException
. - Close the
RpcClient
. - Repeat 1.-3. using the same channel.
Observe that first there will be an exception, then there will be an exception and a log-warning, then an exception and two log-warnings, then an exception and three log-warnings and so on. The reason is that each new RpcClient
adds its own ReturnListener
. One of them throws the exception, the other log warnings, because they look up the returned message in the previous RpcClient
's continuation maps.
The log messages are annoying, but more importantly, the listeners accumulate over time and live for as long as the channel stays open.
Expected behavior
Closing an RpcClient
should clean up thoroughly, including the removal of the ReturnListener
so that the channel may be reused.
Additional context
No response