Skip to content

Instantly share code, notes, and snippets.

@bookwar
Created May 22, 2020 13:40
Show Gist options
  • Save bookwar/749dabe3e5549621ff294b5f344cfdb4 to your computer and use it in GitHub Desktop.
Save bookwar/749dabe3e5549621ff294b5f344cfdb4 to your computer and use it in GitHub Desktop.
from fedora_messaging import api, config
config.conf.setup_logging()
def printer_callback(message):
"""
Print the message to standard output.
Args:
message (fedora_messaging.message.Message): The message we received
from the queue.
"""
print(str(message))
queues = {
'589139bf-69ec-437c-8dfa-05d2d07a72de': {
'durable': False, # Delete the queue on broker restart
'auto_delete': True, # Delete the queue when the client terminates
'exclusive': False, # Allow multiple simultaneous consumers
'arguments': {},
},
}
binding = {
'exchange': 'amq.topic', # The AMQP exchange to bind our queue to
'queue': '589139bf-69ec-437c-8dfa-05d2d07a72de', # The unique name of our queue on the AMQP broker
'routing_keys': ['#'], # The topics that should be delivered to the queue
}
# Start consuming messages using our callback. This call will block until
# a KeyboardInterrupt is raised, or the process receives a SIGINT or SIGTERM
# signal.
api.consume(printer_callback, bindings=binding, queues=queues)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment