#!/usr/bin/env python
#-*- coding: utf8 -*-
import pika
import traceback
try:
connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.4.226'))
channel = connection.channel()
except:
print traceback.print_exc()
def rabbitmq_send(abcde):
try:
channel.queue_declare(queue='abcde')
except:
print traceback.print_exc()
try:
mess = "<message><name>abcde</name><item key='abcde'>%s</item></message>" %abcde
channel.basic_publish(exchange='',
routing_key='abcde',
body = mess)
print '[x] Send abcde'
except:
print traceback.print_exc()
try:
connection.close()
except:
print traceback.print_exc()
if __name__ == "__main__":
sc = rabbitmq_send('abcde')