Created
December 3, 2012 15:30
-
-
Save russellb/4195727 to your computer and use it in GitHub Desktop.
Qpid consumer of Nova notifications
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": "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