linux – RabbitMQ,麻烦得到hello world示例除了localhost之外的
发布时间:2020-12-14 03:00:02 所属栏目:Linux 来源:网络整理
导读:我正在学习RabbitMQ,并在 http://www.rabbitmq.com/tutorials/tutorial-one-python.html运行hello world示例,localhost没有问题.现在我想测试从我的PC到另一台服务器的消息,receive.py似乎永远不会得到任何消息.也许我没有正确指定主机名? Receive.py: #!/
我正在学习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.您可能想要在安装中检查该设置. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |