[rabbitmq-discuss] message acknowledment

Rob Harrop rob at rabbitmq.com
Thu Oct 14 19:23:36 BST 2010


Thanks to Matthias for noticing I set noAck=true in both examples. The second example should start:
	
	try {
		GetResponse theResp = channel.basicGet("queue", false);

Rob

On 14 Oct 2010, at 19:16, Rob Harrop wrote:

> When you consume a message, either with basic.get or basic.consume you have control over the noAck flag. 
> 
> When you set noAck=true, messages are considered automatically acknowledged as soon as they have been delivered.
> 
> With noAck=false, messages must be acknowledged manually with basic.ack.
> 
> 
> For example, in Java, you can use noAck=true like this:
> 
> 	GetResponse theResp = channel.basicGet("queue", true);
> 	// message is acknowledged now and won't be redelivered for this queue
> 
> With noAck=false:
> 
> 	try {
> 		GetResponse theResp = channel.basicGet("queue", true);
> 		if(theResp != null) {
> 			doSomething(theResp);
> 			channel.basicAck(theResp.getEnvelope().getDeliveryTag(), false);
> 		}
> 	catch(Exception ex) {
> 		// processing error, close the channel
> 		channel.close();
> 	}
> 
> After the channel is closed, the message will be redelivered to another consumer on that queue.
> 
> Hope this helps!
> 
> Rob
> 
> On 13 Oct 2010, at 08:21, MOTEW wrote:
> 
>> 
>> hello to all.
>> i am working on rabbitmq 
>> if the consumer get the mesage will he send some acknowledment to
>> rabbitmq???
>> 
>>>> or what about  rabbitmq acknowledment policies???
>> 
>>>> if the message is lost whether due to node down or else how it is
>> relievered to the consumer without any error message to the publisher????and
>> also after successful delievery we want to delete it from broker's queue???
>> 
>> any help is appreciable
>> 
>> 
>> 
>> -- 
>> View this message in context: http://old.nabble.com/message-acknowledment-tp29950181p29950181.html
>> Sent from the RabbitMQ mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> 
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss



More information about the rabbitmq-discuss mailing list