Skip to content

Instantly share code, notes, and snippets.

@russellb
Created December 3, 2012 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russellb/4195727 to your computer and use it in GitHub Desktop.
Save russellb/4195727 to your computer and use it in GitHub Desktop.
Qpid consumer of Nova notifications
import json
import sys
import qpid.messaging
def main(argv=None):
if argv is None:
argv = sys.argv
connection = qpid.messaging.Connection('localhost:5672')
connection.reconnect = True
connection.open()
addr_opts = {
"create": "always",
"node": {
"type": "topic",
"x-declare": {
"durable": True,
"auto-delete": True,
},
},
"link": {
"name": "notifications.*",
"durable": True,
"x-declare": {
"durable": False,
"auto-delete": True,
"exclusive": False,
},
},
}
address = "nova/notifications.* ; %s" % json.dumps(addr_opts)
session = connection.session()
receiver = session.receiver(address)
receiver.capacity = 1
while True:
try:
msg = receiver.fetch()
print msg
except KeyboardInterrupt:
break
return 0
if __name__ == '__main__':
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment