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.

Channel.basic_consume doesn't support consume-ok/completion callback

See original GitHub issue

Channel.basic_consume doesn’t provide an argument for specifying the completion callback to be called upon consume-ok. (the callback arg that it presently supports is for consuming incoming messages).

A client’s logic might need to know that the basic-consume request succeeded before initiating other operations (e.g., when requesting exclusive access). Lack of the completion callback prevents the application from doing so easily.

Implementation notes:

  1. Rename Channel.basic_consume’s consumer callback (presently named callback) to consumer_callback, message_callback, message_rx_callback, or similar, and name the completion callback callback to follow the recently-established convention for naming of completion callbacks. Also rename the consumer callback arg in BlockingChannel.basic_consume for consistency with Channel.basic_consume.
  2. If completion callback isn’t specified, auto-generate and return the consumer tag following the legacy behavior. If completion callback is specified, return None from Channel.basic_consume and let the server generate the consumer tag and return it via consume-ok. Update the docstring in Channel.basic_consume to reflect this.
  3. Make sure pika’s Channel._generate_consumer_tag doesn’t generate consumer tags that can potentially collide with server-generated ones by prefixing “pika” into the consumer tag name that Channel._generate_consumer_tag generates.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vitaly-kruglcommented, Feb 10, 2018

I’m wondering about how I can replace the existing behavior with regard to consumer tag with a server-generated one …

@lukebakken, I supposed the easiest for now is to continue to generate the consumer tag in pika as we do presently.

In theory, you could cache the consumer callbacks in a list and then match them with tags returned in consumer-ok, which should return in the given order. Another option could be to have an API method that the app could call to register the consumer callback for a consumer tag once it is known. Still, continuing to generate the consumer tag in pika seems like the safest and simplest approach with no apparent downside.

1reaction
vitaly-kruglcommented, Feb 9, 2018

cc @lukebakken It would be great to get this API change in before pika 1.0 as it has implications on the callback arg name changed in your recent PR #941

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Client API Guide - RabbitMQ
Channel -level exceptions such as attempts to consume from a queue that does not exist will result in channel closure. A closed channel...
Read more >
Publishing to queue in cosumer callback using RabbitMQ
While I'm able to acknowledge the message fine, attempting to publish a message to the channel does nothing. Below is an example:
Read more >
Channel (RabbitMQ Java Client 4.12.0 API)
Channel instances must not be shared between threads. Applications should prefer using a Channel per thread instead of sharing the same Channel across ......
Read more >
AutorecoveringChannel (RabbitMQ Java Client 5.7.3 API)
Returns the number of consumers on a queue. This method assumes the queue exists. If it doesn't, the channel will be closed with...
Read more >
Channel — pika 1.2.1 documentation - Read the Docs
Callbacks should allow for the frame parameter to be passed in. ... parameter in the basic.consume AMQP 0.9.1 method; exclusive (bool) – Don't...
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