Reputation: 852
When RabbitMQ disk usage or memory usage reaches the higher threshold RabbitMQ will block connection
In the spring amqp whenever rabbitMQ blocks the connection there is no error message about the connection failure
is there is any way to set timeout for a publish in spring amqp?
Thanks in advance
Upvotes: 3
Views: 953
Reputation: 852
Blocking connection listener is not enabled in Spring amqp by default, we need to add Blocked connection listener to the rabbitmq connection factory bean for getting blocked connection notification.
Following code will works :
connectionFactory.addConnectionListener(new ConnectionListener() {
@Override
public void onCreate(Connection connection) {
Channel channel = connection.createChannel(false);
channel.getConnection().addBlockedListener(new BlockedListener() {
@Override
public void handleUnblocked() throws IOException {
}
@Override
public void handleBlocked(String reason) throws IOException {
}
});
try {
channel.close();
}
catch (IOException e) {
}
}
@Override
public void onClose(Connection connection) {
}
});
Reference
Upvotes: 1