Yes, DefaultConsumer uses an internal thread pool that can be changed. Using ExecutorService as:
ExecutorService es = Executors.newFixedThreadPool(20); Connection conn = factory.newConnection(es);
Read the http://www.rabbitmq.com/api-guide.html Advanced Connection Settings.
As you can read from the "QueueingConsumer" doc :
Thus, it is now safe to implement the Consumer directly or extend the DefaultConsumer.
I have never used QueueingConsumer because it is not event driven.
As you can see here:
QueueingConsumer consumer = new QueueingConsumer(channel); channel.basicConsume(QUEUE_NAME, true, consumer); while (true) { QueueingConsumer.Delivery delivery = consumer.nextDelivery();
A typical problem in this case is how to close the subscription, and a common workaround is to send the private message tag on the local host. I donβt really like it.
If you extend the DefaultConsumer , you can properly close the subscription and channel:
public class MyConsumer extends DefaultConsumer {...}
then
public static void main(String[] args) { MyConsumer consumer = new MyConsumer (channel); String consumerTag = channel.basicConsume(Constants.queue, false, consumer); System.out.println("press any key to terminate"); System.in.read(); channel.basicCancel(consumerTag); channel.close(); ....
In conclusion, you do not have to worry about the message order, because if everything works correctly, the message order is correct, but I think you canβt accept it, because if there is any problem, you can lose the message order. If you absolutely need to maintain message order, you must include a sequential tag to restore message order on the consumer side.
And you have to expand DefaultConsumer.