[rabbitmq-discuss] Problem transferring large message
fred basset
fredbasset1000 at gmail.com
Tue Aug 21 00:46:46 BST 2012
Hi All,
I have a simple producer and consumer based on the hello world
example. My code works for small messages (sending a 64 byte log
file), but for larger messages (a 53KB log file) the receiver never
seems to get the message. I am using all the defaults and am on
Ubuntu server using the Pika library. Any clues as to what could be
wrong?
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))
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='logupload')
print ' [*] Waiting for messages. To exit press CTRL+C'
def callback(ch, method, properties, body):
data = json.loads(body)
fname = "logs/x14/" + data["filename"]
logfile = open(fname, "w")
logfile.write(data["logdata"])
logfile.close()
print "Wrote " + fname
channel.basic_consume(callback,
queue='logupload',
no_ack=True)
channel.start_consuming()
More information about the rabbitmq-discuss
mailing list