SharedQueue closed error

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

SharedQueue closed error

anate
I declared a queue with persistent message using PHP and trying to consume the message in C#. I received 'SharedQueue closed error' at this line.
       channel.BasicAck(ea.DeliveryTag, false);
I am assuming the persistent  message shouldn't delete from queue but after Dequeue() message getting deleted. Could you please let me know if there are any suggestions.

PHP(Publish)
-----
$channel->queue_declare('hello-queue', false, true, false, false);

$message = "Hello World....";

try{

$msg = new AMQPMessage($message,
                        array('delivery_mode' => 2) # make message persistent
                      );
$channel->basic_publish($msg, '', 'hello-queue');
}
catch (AMQPChannelException $exception)
{
   echo "The channel is not open (publishing message on queue).\n";
}

Consume(C#)
---------------

            using (IConnection connection = connectionFactory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                      channel.QueueDeclare("hello-queue", true, false, false, null);

                    var consumer = new QueueingBasicConsumer(channel);
                    channel.BasicConsume("hello-queue", true, consumer);

                    while (true)
                    {
                        try
                        {
                            var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();

                            InsertData(message);

                            channel.BasicAck(ea.DeliveryTag, false);
                        }
                        catch (RabbitMQ.Client.Exceptions.OperationInterruptedException ex)
                        {
                            break;
                        }
                    }
                }
            }
Reply | Threaded
Open this post in threaded view
|

Re: SharedQueue closed error

Alvaro Videla-2
If you ack the message on the consumer side, then the message will be
removed from the queue.

On Wed, Apr 2, 2014 at 10:39 PM, anate <[hidden email]> wrote:

> I declared a queue with persistent message using PHP and trying to consume
> the message in C#. I received 'SharedQueue closed error' at this line.
>        channel.BasicAck(ea.DeliveryTag, false);
> I am assuming the persistent  message shouldn't delete from queue but after
> Dequeue() message getting deleted. Could you please let me know if there are
> any suggestions.
>
> PHP(Publish)
> -----
> $channel->queue_declare('hello-queue', false, true, false, false);
>
> $message = "Hello World....";
>
> try{
>
> $msg = new AMQPMessage($message,
>                         array('delivery_mode' => 2) # make message
> persistent
>                       );
> $channel->basic_publish($msg, '', 'hello-queue');
> }
> catch (AMQPChannelException $exception)
> {
>    echo "The channel is not open (publishing message on queue).\n";
> }
>
> Consume(C#)
> ---------------
>
>             using (IConnection connection =
> connectionFactory.CreateConnection())
>             {
>                 using (var channel = connection.CreateModel())
>                 {
>                       channel.QueueDeclare("hello-queue", true, false,
> false, null);
>
>                     var consumer = new QueueingBasicConsumer(channel);
>                     channel.BasicConsume("hello-queue", true, consumer);
>
>                     while (true)
>                     {
>                         try
>                         {
>                             var ea =
> (BasicDeliverEventArgs)consumer.Queue.Dequeue();
>
>                             InsertData(message);
>
>                             channel.BasicAck(ea.DeliveryTag, false);
>                         }
>                         catch
> (RabbitMQ.Client.Exceptions.OperationInterruptedException ex)
>                         {
>                             break;
>                         }
>                     }
>                 }
>             }
>
>
>
> --
> View this message in context: http://rabbitmq.1065348.n5.nabble.com/SharedQueue-closed-error-tp34504.html
> Sent from the RabbitMQ mailing list archive at Nabble.com.
> _______________________________________________
> rabbitmq-discuss mailing list
> [hidden email]
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: SharedQueue closed error

Michael Klishin-2
In reply to this post by anate
On 3 April 2014 at 00:40:40, anate ([hidden email]) wrote:
> > I declared a queue with persistent message using PHP and trying  
> to consume
> the message in C#. I received 'SharedQueue closed error' at this  
> line.

What is in RabbitMQ log (when you see the exception)?

> channel.BasicAck(ea.DeliveryTag, false);
> I am assuming the persistent message shouldn't delete from queue  
> but after
> Dequeue() message getting deleted.

Your understanding is not correct. Persistent messages survive RabbitMQ
restart. They are deleted from the queue when they are acknowledged.

Since you use channel.BasicConsume("hello-queue", true, consumer),
messages are considered to be acknowledged as soon as RabbitMQ sends
them out to consumers. There is no need to ack them (and acking them
will result in a protocol exception).

QueueingConsumer will accumulate deliveries locally in a shared queue.
My guess is that QueueingConsumer shuts the shared internal queue down
when a protocol exception occurs.

Judging from your code you don’t need to use a QueueingConsumer. Simply
subclass DefaultConsumer and override HandleDelivery.

HTH. 
--  
MK  

Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: SharedQueue closed error

anate
In reply to this post by Alvaro Videla-2
Thank you. I am not sure why am I getting SharedQueue closed error message. Could you please let me know?
Reply | Threaded
Open this post in threaded view
|

Re: SharedQueue closed error

anate
In reply to this post by Michael Klishin-2
Thank you for the reply. I am trying to insert the data into database and would like to keep the message in RabbitMQ if the insert fails. I am not sure if I am in right path. Could you please let me know more info about "subclass DefaultConsumer and override HandleDelivery"? Please let me know if there are any code examples.

> QueueingConsumer will accumulate deliveries locally in a shared queue.
> My guess is that QueueingConsumer shuts the shared internal queue down
> when a protocol exception occurs.

> Judging from your code you don’t need to use a QueueingConsumer. Simply
> subclass DefaultConsumer and override HandleDelivery.
Reply | Threaded
Open this post in threaded view
|

Re: SharedQueue closed error

anate
In reply to this post by Michael Klishin-2
Here is the error message in the logs.

{amqp_error,precondition_failed,
            "parameters for queue 'hello-queue' in vhost '/' not equivalent",
            'queue.declare'}

channel 1 - soft error:
{amqp_error,precondition_failed,"unknown delivery tag 1",'basic.ack'}:
connection_closed_abruptly
Reply | Threaded
Open this post in threaded view
|

Re: SharedQueue closed error

Michael Klishin-2
In reply to this post by anate
On 3 April 2014 at 18:10:27, anate ([hidden email]) wrote:
> > Thank you for the reply. I am trying to insert the data into database  
> and
> would like to keep the message in RabbitMQ if the insert fails.  
> I am not
> sure if I am in right path

You need to use manual acknowledgement mode:
http://www.rabbitmq.com/tutorials/tutorial-two-dotnet.html 
--  
MK  

Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: SharedQueue closed error

Michael Klishin-2
In reply to this post by anate
On 3 April 2014 at 18:21:29, anate ([hidden email]) wrote:
> > {amqp_error,precondition_failed,
> "parameters for queue 'hello-queue' in vhost '/' not
> equivalent",
> 'queue.declare'}
>  
> channel 1 - soft error:
> {amqp_error,precondition_failed,"unknown delivery tag  
> 1",'basic.ack'}:
> connection_closed_abruptly

This is exactly the error I mentioned earlier in this thread.

Use manual acknowledgements and set a basic.qos limit (say, 25-50 messages)
on the channel you use.

basic.qos and requeueing are covered in Tutorial 2:
http://www.rabbitmq.com/tutorials/tutorial-two-dotnet.html 
--  
MK  

Software Engineer, Pivotal/RabbitMQ
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss