[rabbitmq-discuss] Re storing a message to the queue

Bamboula aloroi18 at gmail.com
Tue Feb 21 14:14:57 GMT 2012


Hi,

Thanks for your quick reply. I think that my problem is not really to
restore a message, because if I check with the RabbitMQ command line (using
"rabbitmqctl list_queues"),I can see that the message I sent is stored in
the queue. My problem is rather to be able to retrieve the message to my
consumer GUI.
 I've created a project (with C# .net) where the consumer can choose whether
he wants to be connected or disconnected from the queue.

When the consumer chooses the disconnect radiobutton, I'm writing in the
consumer form:

consumer.onMessageReceived -= handleMessage;

This causes to go to the catch of this loop:
 
            while (isConsuming)
            {
                try
                {
                    RabbitMQ.Client.Events.BasicDeliverEventArgs e =
(RabbitMQ.Client.Events.BasicDeliverEventArgs)consumer.Queue.Dequeue();

                    IBasicProperties props = e.BasicProperties;
                    byte[] body = e.Body;
                    // ... process the message
                    onMessageReceived(body);
                    Model.BasicAck(e.DeliveryTag,true);

                }
                catch
                {
                    Model.BasicCancel(consumerTag);
                    break;
                }

Now, the producer sends a message, and the message is stocked in the queue.
Then, the consumer chooses the Connect RadioButton. I'm expecting to see the
message on the consumer GUI, but I'm not.
I checked the consumer instance's properties during debugging and I saw
that:m_queue count=0. This explains why I don't see any message on my
consumer GUI.

If I do the same experience with more than one message, I will be able to
retrieve all the messages except the first one.

I think that the reason to this is that the consumer instance goes through a
Dequeue() before the user chooses the disconnect radiobutton and maybe due
to this, there is no possibility to retrieve the message from the queue.
But maybe I'm wrong. However, the problem is still the same: I can't
retrieve the first message.

Could you help me?if you can't, give me a link to someone who could help.
Thanks a lot,I've been working on this for several days

Bamboula

Alvaro Videla-2 wrote:
> 
> Hi,
> 
> It all depends on why you want the message to be back in the queue. Also
> do
> you want the exact message to be back in the queue or just the contents of
> it?
> 
> If you want the exact message you can basic.reject it I guess. See the
> Spec
> here: http://www.rabbitmq.com/amqp-0-9-1-quickref.html
> 
> If you just want the msg body back in the queue then you can republish the
> message body.
> 
> Regards,
> 
> Alvaro
> 
> On Tue, Feb 21, 2012 at 10:29 AM, Bamboula <aloroi18 at gmail.com> wrote:
> 
>>
>> After using Dequeue() to my queue, I want to restore the retrieved
>> message
>> to
>> the queue. Is this possible?
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Restoring-a-message-to-the-queue-tp33362597p33362597.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
> 
> 

-- 
View this message in context: http://old.nabble.com/Restoring-a-message-to-the-queue-tp33362597p33364165.html
Sent from the RabbitMQ mailing list archive at Nabble.com.



More information about the rabbitmq-discuss mailing list