我正在学习RabbitMQ,并在
http://www.rabbitmq.com/tutorials/tutorial-one-python.html运行hello world示例,localhost没有问题.现在我想测试从我的PC到另一台服务器的消息,receive.py似乎永远不会得到任何消息.也许我没有正确指定主机名?
Receive.py:
#!/usr/bin/env python import pika import json connection = pika.BlockingConnection(pika.ConnectionParameters( host='66.175.x.x')) channel = connection.channel() channel.queue_declare(queue='hello') print ' [*] Waiting for messages. To exit press CTRL+C' def callback(ch,method,properties,body): data = json.loads(body) print "Log filename is " + data["filename"] print data["content"] channel.basic_consume(callback,queue='hello',no_ack=True) channel.start_consuming()
send.py:
#!/usr/bin/env python import pika import json import sys filename = sys.argv[1] logdata = open(filename,'r').read() connection = pika.BlockingConnection(pika.ConnectionParameters( host='66.175.x.x')) channel = connection.channel() channel.queue_declare(queue='logupload') n = filename.rfind('\\') if n != -1: filename = filename[n + 1:] data = {"filename":filename,"logdata":logdata} channel.basic_publish(exchange='',routing_key='logupload',body=json.dumps(data)) connection.close() print "sent %s %d bytes" % (filename,len(logdata))
解决方法
RabbitMQ –
http://www.rabbitmq.com/configure.html
见frame_max.默认情况下支持128KB.您可能想要在安装中检查该设置.