Search code examples
spring-bootrabbitmqspring-rabbit

Using RabbitListener annotation to create priority queues in Spring Boot


@RabbitListener(bindings = @QueueBinding(value = @Queue(value = "${queue}",
                durable = "true", autoDelete = "false",
                exchange = @Exchange(value = "${exchange}"),
                key = "${binding}"),concurrency = "${concurrency}")

This creates a queue, how do I go about creating a priority queue?


Solution

  • So I found that the existing queues should be deleted and the exchanges as well. And the following code creates a priority queue. I looked for this online, but couldn't find any answers. So, I am posting this here.

    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = "${queue}",
                    durable = "true", autoDelete = "false",
                    arguments = {@Argument(name = "x-max-priority", value = "10",
                    type = "java.lang.Integer")}),
                    exchange = @Exchange(value = "${exchange}"),
                    key = "${binding}"),concurrency = "${concurrency}")