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

Matthias Radestock matthias at rabbitmq.com
Mon May 13 11:23:47 BST 2013


On 10/05/13 09:48, Ahmet Akyol wrote:
> 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.

That *should* work. What problems did you encounter?

> So, is there a full working example of "DefaultConsumer"

https://github.com/rabbitmq/rabbitmq-java-client/blob/master/test/src/com/rabbitmq/examples/ConsumerMain.java#L232


Matthias.


More information about the rabbitmq-discuss mailing list