We have a service that send a message in a rabbit queue configure like this:
spring:
cloud:
stream:
bindings:
output:
destination: test
rabbit:
bindings:
output:
producer:
routingKeyExpression: headers.version
After having sent a very large number of messages during our bench tests, we noticed that the connection to the message queue is blocked: Blocked queue
It seems that the blockage comes when the RabbitMQ server uses above 40% of the available RAM, it raises a memory alarm and blocks all connections that are publishing messages.
Our problem is that in this particular case, we lose the messages sent in the queue.
How to avoid loss of messages using spring cloud stream. Here's a snippet of our class:
@Service
@EnableBinding(Source.class)
public class OurService {
Source source;
public void send(OurMessage ourMessage, Map<String, Object> headers) {
source.output().send(MessageBuilder.createMessage(ourMessage, new MessageHeaders(headers))));
}
}
This code does not return any exception even though the queue is blocked. Is there a way to know the status of the queue (blocked) before sending the messages?