python rabbitmq 消费端根据能力轮询接受
import pikaconnection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello',durable=True)##队列持久化,队列重启后也存在,不保证数据是否存在
# channel.queue_delete(queue="task_queue")
for i in range(100):
channel.basic_publish(exchange='',
routing_key='hello',
body=str(i),
properties=pika.BasicProperties(delivery_mode=2) ##数据持久化
)
# print("Sent 'hello world!'")
connection.close()
页:
[1]