1

Hi I am looking for simple solution on rabbit mq. Below are the settings been done on the rabbit.

  1. Start the rabbit server
  2. create exchange (myexchange) of type topic with durable option.
  3. create the queue (myqueue) with durable option and x-max-length-bytes set to 4 and x-max-length set to 2.
  4. Bind the myexchange with myrouting to myqueue.
  5. Publish message using the basic_publish using aqmp channel (channel.basicPublish(myexchange, myrouting, true, null, "test".getBytes("UTF-8"));
  6. Use publisher confirm settings like channel.confirmSelect(); and channel.waitForConfirmsOrDie();

Code snippet below

channel = connectionFactory.getChannel();
channel.queueDeclarePassive("myqueue");
channel.confirmSelect();
channel.basicPublish("myexchange", "myrouting", true, 
        null, "test".getBytes("UTF-8"));
channel.waitForConfirmsOrDie();

Now the rabbit mq is not replying with error for the number of messages exceeded/size exceeded. I could able to send 1000 messages/with 1kb size and the consumer also consuming all these messages. So how could I get the error code? Any help on this please?

vrit
  • 11
  • 3

1 Answers1

1

The RabbitMQ team monitors this mailing list and only sometimes answers questions on StackOverflow.


There are two items you need to consider here. First, your consumer may be consuming messages fast enough that the limit is never reached.

Second, when a queue length limit is hit, messages are dropped from the head of the queue to make room for new messages. This means that you will lose the oldest messages in the queue - docs. This behavior will be configurable in 3.7.0.

However, in no case will an error be returned, so I don't know why you think an error will be returned. The documentation is clear on what happens when a queue limit is reached.

Luke Bakken
  • 8,993
  • 2
  • 20
  • 33
  • Thank you Luke, what is the best way to get the number of messages dropped in this scenario. Am I correct to use the consumer acks/nacks mechanism to get the number of messages been consumed. – vrit Nov 13 '17 at 14:11
  • Thank you Luke, what is the best way to get the number of messages dropped in this scenario (If I am not using the deadletter queue). Am I correct to use the consumer acknowledgement mechanism to find the message has been delivered to queue successfully. (Assuming I am making a blocking call to send the message to queue). – vrit Nov 13 '17 at 14:19
  • Yes, you need to use [publisher confirms](https://www.rabbitmq.com/confirms.html) to be certain that your message has been published. Using a dead-letter exchange is the only way to know the count of messages dropped. If my original answer and this follow-up are sufficient, please mark my response as the accepted answer. – Luke Bakken Nov 15 '17 at 16:17
  • You're welcome. If you're satisfied with my response, could you please mark it as the accepted answer? – Luke Bakken Nov 22 '17 at 14:56