Channel.basic_consume doesn't support consume-ok/completion callback
See original GitHub issueChannel.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:
- Rename
Channel.basic_consume
’s consumer callback (presently namedcallback
) toconsumer_callback
,message_callback
,message_rx_callback
, or similar, and name the completion callbackcallback
to follow the recently-established convention for naming of completion callbacks. Also rename the consumer callback arg inBlockingChannel.basic_consume
for consistency withChannel.basic_consume
. - 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 inChannel.basic_consume
to reflect this. - 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:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
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