2024-04-18 03:50:37 发布
网友
我想知道是否可以设置队列中的最大消息数
假设我希望队列Foo中的msg不超过100个,可以这样做吗
像这样做吧,开心点
import pika QUEUE_SIZE = 5 connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() channel.queue_declare( queue='ids_queue', arguments={'x-max-length': QUEUE_SIZE} )
在这里的参数中您还需要跟踪队列的队列溢出行为
是的,这是可能的
从official documentation
The maximum length of a queue can be limited to a set number of messages by supplying the x-max-length queue declaration argument with a non-negative integer value.
好了,pika的channel.queue_declare有queue\u declare有arguments参数,这绝对是您想要的
channel.queue_declare
arguments
像这样做吧,开心点
在这里的参数中您还需要跟踪队列的队列溢出行为
是的,这是可能的
从official documentation
好了,pika的
channel.queue_declare
有queue\u declare有arguments
参数,这绝对是您想要的相关问题 更多 >
编程相关推荐