def publish(queue_name,body='Hello World!',exchange=''):
"""Publish the content or message to the queue
pika.BasicProperties(delivery_mode=2) will make message persistent
Args:
queue_name: the mq`s name
body(str) —— the content will be publish
exchange:
"""
channel = get_channel(queue_name)
if channel:
channel.basic_publish(exchange=exchange,
routing_key=queue_name,
body=body,properties=pika.BasicProperties(delivery_mode=2))
# logger.info('ramq publish queue_name: ' + str(queue_name) + ' ,body: \n' + str(body) + '\n')
# print(" [x] Sent " + body)
评论列表
文章目录