关于RabbitMQ的消费者问题
RabbitMQ消费者如何一次只消费一条数据,而不是全部消费;我用以下代码会报错
def consumer(request): credentials = pika.PlainCredentials('xxxx', '123456')# mq用户名和密码
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='xxxxx', port=5672, credentials=credentials))# 定义连接池
channel = connection.channel()
channel.basic_consume(on_message_callback=callback, queue='test', auto_ack=True)
channel.basicQos(1)
channel.start_consuming()# 开始监听 接受消息
return HttpResponse("success") 最终我只能够通过多个消费者来平均消费,但是并不能实现指定消费一条或者几条
页:
[1]