排第四偶家 发表于 2018-8-13 11:00:53

python rabbitmq 消费端根据能力轮询接受

import pika  

  
connection = 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]
查看完整版本: python rabbitmq 消费端根据能力轮询接受