rabbitmq使用__python客户端(消息发送者)

#! /usr/bin/python
# -*- coding: utf-8 -*- 

import sys
import amqplib.client_0_8 as amqp


# 创建一个TCP 连接
conn = amqp.Connection(host="localhost:5672 ", userid="guest",
password="guest", virtual_host="/", insist=False)
# 创建一个通信channel 
chan = conn.channel()


msg = amqp.Message(sys.argv[1])
msg.properties["delivery_mode"] = 2
chan.basic_publish(msg,exchange="sorting_room",routing_key="jason")

chan.close()
conn.close()

你可能感兴趣的:(rabbitmq)