Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 11th, 2012  |  syntax: None  |  size: 1.06 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import json
  2. import sys
  3.  
  4. import qpid.messaging
  5.  
  6.  
  7. def main(argv=None):
  8.     if argv is None:
  9.         argv = sys.argv
  10.  
  11.     connection = qpid.messaging.Connection('localhost:5672')
  12.     connection.reconnect = True
  13.     connection.open()
  14.  
  15.     addr_opts = {
  16.         "create": "always",
  17.         "node": {
  18.             "type": "topic",
  19.             "x-declare": {
  20.                 "durable": True,
  21.                 "auto-delete": True,
  22.             },
  23.         },
  24.         "link": {
  25.             "name": "glance_notifications.*",
  26.             "durable": True,
  27.             "x-declare": {
  28.                 "durable": False,
  29.                 "auto-delete": True,
  30.                 "exclusive": False,
  31.             },
  32.         },
  33.     }
  34.  
  35.     address = "glance/glance_notifications.* ; %s" % json.dumps(addr_opts)
  36.  
  37.     session = connection.session()
  38.     receiver = session.receiver(address)
  39.     receiver.capacity = 1
  40.  
  41.     while True:
  42.         try:
  43.             msg = receiver.fetch()
  44.             print msg
  45.         except KeyboardInterrupt:
  46.             break
  47.  
  48.     return 0
  49.  
  50.  
  51. if __name__ == '__main__':
  52.     sys.exit(main())