New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the NACK during the stop_consuming #1389
Comments
Thanks for the report! I'm the author of the original SO question, let me know if you need anything. |
I edited the SO question with an even simpler example to trigger the bug, I'll post it here: Client #!/usr/bin/env python
import pika
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost')
)
channel_stream = connection.channel()
channel_stream.queue_declare(
"stream-queue",
durable=True,
arguments={
'x-queue-type': 'stream',
}
)
for i in range(2):
channel_stream.basic_publish(
exchange='',
routing_key='stream-queue',
body=f"stream data".encode()
)
connection.close() Server #!/usr/bin/env python
import pika
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost')
)
channel_stream = connection.channel()
channel_stream.queue_declare(
"stream-queue",
auto_delete=False, exclusive=False, durable=True,
arguments={
'x-queue-type': 'stream',
}
)
channel_stream.basic_qos(
prefetch_count=1,
)
class Server(object):
def __init__(self):
channel_stream.basic_consume(
queue="stream-queue",
on_message_callback=self.stream_callback,
)
def stream_callback(self, channel, method, props, body):
print(f"received '{body.decode()}' via {method.routing_key}")
channel_stream.stop_consuming()
server = Server()
try:
channel_stream.start_consuming()
except KeyboardInterrupt:
connection.close() |
Thank you @tango-taylor for reporting. |
I'm writing an app that consuming a streaming queue and posts the results to a streamlit app. I have to hand control back to streamlit by periodically starting and stopping message consumption. I'm still figuring out the best way to do this and along the way ran into the same problem when I call |
@fizix137 FYI, there is a separate Python client for streams that does not have Pika's limitations. |
In fact, there is more than one Python client for RabbitMQ streams :) |
I've tested SelectConnection and found the same behavior, if you setup a queue of type stream the error appears while processing a message and a basic_cancel is fired in the middle, the _on_deliver function doesn't take care that you're using a Channel for consuming a stream queue and sends the basic_reject method when it must not do it. |
Per conversation with @michaelklishin @lukebakken
Remove the
nack
during thechannel.stop_consuming
when the channel is closing the nack is not necessarySee also the SO question.
Internal link
The text was updated successfully, but these errors were encountered: