Application Scenario
In the default direct mode, multiple consumers subscribe to a queue and messages are sent to each consumer in turn. In single-consumer mode, a message is consumed by only one consumer, unless exception occurs on the consumer. This ensures that message consumption is organized.
Example of Use
The following is an example of the Java client that implements a single active consumer by configuring the x-single-active-consumer parameter when declaring a queue.
Map<String, Object> arguments = newHashMap<String, Object>();
arguments.put("x-single-active-consumer", true);
channel.queueDeclare("test_queue", false, false, false, arguments);