While requeuing the message we want the message to be placed at the start/front of the queue. This means if I have in queue as "D,C,B,A" and process A and then want to put back in Queue at start, my queue should looks like this:- "A,D,C,B". So, I should be able to process B, and since A moved at start of the queue should process it at end.
Interestingly, when tried with native AMQP library of rabbitMQ it wworks as expected above.
However, when we do it through spring AMQP library , the message still remains whereever it was, does not go to the front of the queue.
Here is the code which we tried:
public void onMessage(Message message, com.rabbitmq.client.Channel channel) throws Exception {
if(new String(message.getBody()).equalsIgnoreCase("A")){
System.out.println("Message ===" + new String(message.getBody()));
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
} else{
System.out.println("Message ===" + new String(message.getBody()));
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
}
}
Any idea why it does not work in Spring but works in the rabbimq amqp native library ?
Spring AMQP version : spring-amqp-1.4.5.RELEASE Rabbitmq amqp client version : 3.5.1