Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (rmq-test)zaz@blackjack ~/rmq-test $ cat test-producer.py
- #!/usr/bin/env python
- import rabbitpy
- import base64
- url = "amqp://USERNAME:PASSWORD@BROKER_HOSTNAME:5672/%%2F"
- print "Opening connection"
- with rabbitpy.Connection(url) as conn:
- print "Opening channel"
- with conn.channel() as channel:
- channel.prefetch_count(1)
- print "Declaring queue"
- queue = rabbitpy.Queue(channel, 'testqueue')
- queue.declare()
- with open('10k_payload', 'r') as fp:
- rawdata = base64.b64encode(fp.read())
- for multiplier in range(1, 20):
- payload = rawdata * multiplier
- print "Payload size is %d bytes" % len(payload)
- print "Sending payload"
- message = rabbitpy.Message(channel, payload)
- message.publish('', routing_key='testqueue')
- (rmq-test)zaz@blackjack ~/rmq-test $ ./test-producer.py
- Opening connection
- Opening channel
- Declaring queue
- Payload size is 13656 bytes
- Sending payload
- Payload size is 27312 bytes
- Sending payload
- Payload size is 40968 bytes
- Sending payload
- Payload size is 54624 bytes
- Sending payload
- Payload size is 68280 bytes
- Sending payload
- Payload size is 81936 bytes
- Sending payload
- Traceback (most recent call last):
- File "./test-producer.py", line 29, in <module>
- message.publish('', routing_key=config['amqp']['queue']['work'])
- File "/Users/zaz/.virtualenvs/rmq-test/lib/python2.7/site-packages/rabbitpy/message.py", line 271, in publish
- self.channel._write_frame(method_frame)
- File "/Users/zaz/.virtualenvs/rmq-test/lib/python2.7/site-packages/rabbitpy/base.py", line 309, in _write_frame
- raise exception
- rabbitpy.exceptions.ConnectionResetException: ('BLANKEDOUT_HOSTNAME', 5672, 'Resource temporarily unavailable')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement