question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Freezing method calls for creating queues, exchanges and bindings

See original GitHub issue

In both Pika 0.13.0 and 1.0.0b1, some method calls for creating queues, exchanges and bindings are freezing (blocking forever instead of returning or raising an exception) with some arguments. These unexpected behaviours are emphasized in bold below.

queue_declare

  • queue_declare() OK, raises TypeError: queue_declare() missing 1 required positional argument: ‘queue’ in Pika 1.0.0b1, creates a queue with a unique name in Pika 0.13.0.
  • queue_declare(queue=None) Unexpected, freezes instead of creating a queue with a unique name.
  • queue_declare(queue="") OK, creates a queue with a unique name.

exchange_declare

  • exchange_declare() Unexpected, freezes instead of raising TypeError: exchange_declare() missing 1 required positional argument: ‘queue’.
  • exchange_declare(exchange=None) Unexpected, freezes instead of raising pika.exceptions.ChannelClosed: (403, ‘ACCESS_REFUSED - operation not permitted on the default exchange’).
  • exchange_declare(exchange="") OK, raises pika.exceptions.ChannelClosed: (403, ‘ACCESS_REFUSED - operation not permitted on the default exchange’).

queue_bind

  • queue_bind() OK, raises TypeError: queue_bind() missing 2 required positional arguments: ‘queue’ and ‘exchange’;
  • queue_bind(queue=None, exchange=None, routing_key=None) Unexpected, freezes instead of raising pika.exceptions.ChannelClosed: (403, ‘ACCESS_REFUSED - operation not permitted on the default exchange’).
  • queue_bind(queue="", exchange="", routing_key="") OK, raises pika.exceptions.ChannelClosed: (403, ‘ACCESS_REFUSED - operation not permitted on the default exchange’).

exchange_bind

  • exchange_bind() Unexpected, freezes instead of raising TypeError: exchange_declare() missing 2 required positional arguments: ‘destination’ and ‘source’.
  • exchange_bind(destination=None, source=None, routing_key=None) Unexpected, freezes instead of raising pika.exceptions.ChannelClosed: (403, ‘ACCESS_REFUSED - operation not permitted on the default exchange’).
  • exchange_bind(destination="", source="", routing_key="") OK, raises pika.exceptions.ChannelClosed: (403, ‘ACCESS_REFUSED - operation not permitted on the default exchange’).

I used a BlockingChannel for all the method calls. For instance:

import pika

parameters = pika.ConnectionParameters()

with pika.BlockingConnection(parameters) as connection:
    channel = connection.channel()
    channel.queue_declare(queue=None)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lukebakkencommented, Jan 30, 2019

@maggyero I will make those changes, thanks.

1reaction
maggyerocommented, Jan 30, 2019

@lukebakken Okay thanks. So if I understood well you added validation for addressing the case:

  • exchange_bind(destination=None, source=None, routing_key=None)

That way instead of freezing the function validators.require_string will raise:

TypeError: destination must be a str or unicode str, but got ‘None’

which addresses one of the six unexpected behaviours that I listed. (And in Pika 1.0.0b2 the function validators.require_string will raise a ValueError instead of the current TypeError.)

I see also that on 22 January 2019 you addressed three other cases by adding the same validation:

  • queue_declare(queue=None)
  • queue_bind(queue=None, exchange=None, routing_key=None)
  • exchange_declare(exchange=None)

So there remains two cases to address:

  • exchange_declare()
  • exchange_bind()

They can be addressed by simply removing the default None arguments in the definitions:

def exchange_declare(self,
                     exchange=None,  # to be replaced by: exchange
                     exchange_type='direct',
                     passive=False,
                     durable=False,
                     auto_delete=False,
                     internal=False,
                     arguments=None):

and

def exchange_bind(self,
                  destination=None,  # to be replaced by: destination
                  source=None,       # to be replaced by: source
                  routing_key='',
                  arguments=None):

That way they the call exchange_declare() would raise

TypeError: exchange_declare() missing 1 required positional argument: ‘exchange’

and the call exchange_bind() would raise:

TypeError: exchange_bind() missing 2 required positional arguments: ‘destination’ and ‘source’

which is consistent with the symmetric calls queue_declare() and queue_bind() which already raise these TypeError.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Part 4: RabbitMQ Exchanges, routing keys and bindings
The consumer creates a queue and sets up a binding with a given routing pattern to the exchange. All messages with a routing...
Read more >
Does RabbitMQ create queue/exchange if already exist?
The RabbitMQ server does not by itself create exchanges or queues. You must use the web admin GUI, a command line tool, or...
Read more >
AMQP 0-9-1 Model Explained - RabbitMQ
Exchanges take a message and route it into zero or more queues. The routing algorithm used depends on the exchange type and rules...
Read more >
Kombu Documentation - Read the Docs
Binding exchanges and queues to a connection will make it use ... callback function is called by kombu every time a new message...
Read more >
Repair failed installations of Exchange Cumulative and ...
This article describes the methods to verify the installation of Microsoft Exchange Server Cumulative Updates (CUs) and Security Updates ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found