username = 'xxxxxxxx' pwd = 'xxxxxxxx' user_pwd = pika.PlainCredentials(username, pwd) s_conn = pika.BlockingConnection(pika.ConnectionParameters('110.318.111.211', credentials=user_pwd)) chan = s_conn.channel() queuename = "pre_weibo_test" exchange = "pre_weibo_test_exchange" routkey = "pre_weibo_test" chan.exchange_declare(exchange,"topic") chan.queue_declare(queue=queuename) chan.queue_bind(queue=queuename, exchange=exchange, routing_key=routkey) chan.basic_publish(exchange=exchange,routing_key=routkey,body=' json data1') s_conn.close()