vrit
vrit

Reputation: 11

Rabbit MQ blocking call to send the message and ensure it gives the right reply code for messages limit exceeded or message size limit exceeded

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?

Upvotes: 1

Views: 1242

Answers (1)

Luke Bakken
Luke Bakken

Reputation: 9627

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.

Upvotes: 1

Related Questions