Advertisement
Guest User

Untitled

a guest
Apr 11th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.69 KB | None | 0 0
  1. (rmq-test)zaz@blackjack ~/rmq-test $ cat test-producer.py
  2. #!/usr/bin/env python
  3.  
  4. import rabbitpy
  5. import base64
  6.  
  7. url = "amqp://USERNAME:PASSWORD@BROKER_HOSTNAME:5672/%%2F"
  8.  
  9. print "Opening connection"
  10. with rabbitpy.Connection(url) as conn:
  11.     print "Opening channel"
  12.     with conn.channel() as channel:
  13.         channel.prefetch_count(1)
  14.         print "Declaring queue"
  15.         queue = rabbitpy.Queue(channel, 'testqueue')
  16.         queue.declare()
  17.         with open('10k_payload', 'r') as fp:
  18.             rawdata = base64.b64encode(fp.read())
  19.  
  20.         for multiplier in range(1, 20):
  21.             payload = rawdata * multiplier
  22.             print "Payload size is %d bytes" % len(payload)
  23.             print "Sending payload"
  24.             message = rabbitpy.Message(channel, payload)
  25.             message.publish('', routing_key='testqueue')
  26.  
  27. (rmq-test)zaz@blackjack ~/rmq-test $ ./test-producer.py            
  28. Opening connection
  29. Opening channel
  30. Declaring queue
  31. Payload size is 13656 bytes
  32. Sending payload
  33. Payload size is 27312 bytes
  34. Sending payload
  35. Payload size is 40968 bytes
  36. Sending payload
  37. Payload size is 54624 bytes
  38. Sending payload
  39. Payload size is 68280 bytes
  40. Sending payload
  41. Payload size is 81936 bytes
  42. Sending payload
  43. Traceback (most recent call last):
  44.   File "./test-producer.py", line 29, in <module>
  45.     message.publish('', routing_key=config['amqp']['queue']['work'])
  46.   File "/Users/zaz/.virtualenvs/rmq-test/lib/python2.7/site-packages/rabbitpy/message.py", line 271, in publish
  47.     self.channel._write_frame(method_frame)
  48.   File "/Users/zaz/.virtualenvs/rmq-test/lib/python2.7/site-packages/rabbitpy/base.py", line 309, in _write_frame
  49.     raise exception
  50. rabbitpy.exceptions.ConnectionResetException: ('BLANKEDOUT_HOSTNAME', 5672, 'Resource temporarily unavailable')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement