Created
February 8, 2012 23:33
-
-
Save russellb/1775426 to your computer and use it in GitHub Desktop.
Receive notifications from Glance via Qpid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "glance_notifications.*", | |
"durable": True, | |
"x-declare": { | |
"durable": False, | |
"auto-delete": True, | |
"exclusive": False, | |
}, | |
}, | |
} | |
address = "glance/glance_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