Rabbitmq uses an rpc blocking call that waits for an indefinite response.
If you look at the Java client api, then what it does:
AMQChannel.BlockingRpcContinuation k = new AMQChannel.SimpleBlockingRpcContinuation(); k.getReply(-1);
Now -1 is passed in blocks of arguments until a response is received.
It's good that you can go to your timeout to return it. The bad thing is that you have to update client banks.
If this is all right, you can time out wherever the blocking call is made, as indicated above. The code will look something like this:
try { return k.getReply(200); } catch (TimeoutException e) { throw new MyCustomRuntimeorTimeoutException("RabbitTimeout ex",e); }
And in your code, you can handle this exception and execute your logic in this case.
Some related classes that may require this fix will be as follows:
com.rabbitmq.client.impl.AMQChannel com.rabbitmq.client.impl.ChannelN com.rabbitmq.client.impl.AMQConnection
FYI: I tried this and it works.
source share