[rabbitmq-discuss] [java-client] Is there a full working example of "DefaultConsumer" without *deprecated * QueueingConsumer ?

Ahmet Akyol liqusha at gmail.com
Fri May 10 09:48:54 BST 2013


Hi everyone,

I'm a RabbitMQ newbie. I try some code with the java client.  Offical site 
tutorial codes are just fine with QueueingConsumer. But then I saw this at 
javadoc:

QueueingConsumer is now deprecated in favour of implementing Consumer 
> directly or extending DefaultConsumer



Then I saw an example usage at api guide<http://www.rabbitmq.com/api-guide.html>

*boolean* autoAck = *false*;
> channel.basicConsume(queueName, autoAck, "myConsumerTag",
>      *new* DefaultConsumer(channel) {
>          @Override
>          *public* *void* handleDelivery(String consumerTag,
>                                     Envelope envelope,
>                                     AMQP.BasicProperties properties,
>                                     *byte*[] body)
>              *throws* IOException
>          {
>              String routingKey = envelope.getRoutingKey();
>              String contentType = properties.contentType;
>              *long* deliveryTag = envelope.getDeliveryTag();
>              *// (process the message components here ...)*
>              channel.basicAck(deliveryTag, *false*);
>          }
>      });
>
>

but it never worked for me. api guide says:

The Java client library distribution is shipped with a 
> rabbitmq-client-tests.jar, containing several small example programs for 
> exercising the functionality of the RabbitMQ server. The source code for 
> these examples is in the test/src folder in the source distribution. 


unfortunately, there isn't such example, all of the consumer codes uses 
QueueingConsume. 

So, is there a full working example of "DefaultConsumer"  or using 
QueueingConsumer is just fine?

Thanks in advance ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130510/b2562a7d/attachment.htm>


More information about the rabbitmq-discuss mailing list