#!/usr/bin/python # -*- coding: utf-8 -*- # Create all the exchanges, queues and other objects in RabbitMQ. # # You must configure the hostname of the RabbitMQ server in # ‘config.py’ first. # # You only have to run this once, but you must run it before running # any other part of patchq. # # All RabbitMQ objects created are prefixed by ‘patchq_...’. To # reverse the effects of this script, delete those objects (using # rabbitmqadmin or similar). import pika import config connection = pika.BlockingConnection(pika.ConnectionParameters( host = config.mq_server)) channel = connection.channel() # Create the input exchange and queue which take raw emails in any # order and queues them so they can be later threaded and ordered (by # ‘threader.py’). channel.exchange_declare(exchange = 'patchq_input', exchange_type = 'fanout', durable = True) q = channel.queue_declare(queue = 'patchq_input', durable = True) channel.queue_bind(exchange = 'patchq_input', queue = q.method.queue) # Create the exchange and queue(s) which take fully threaded and # ordered patch series and passes them to the tests. channel.exchange_declare (exchange = 'patchq_thread', exchange_type = 'fanout', durable = True) for t in config.tests: qname = "patchq_test_%s" % t q = channel.queue_declare(queue = qname, durable = True) channel.queue_bind(exchange = 'patchq_thread', queue = q.method.queue) # Create the email results queue. channel.exchange_declare(exchange = 'patchq_reports', exchange_type = 'fanout', durable = True) q = channel.queue_declare(queue = 'patchq_reports', durable = True) channel.queue_bind(exchange = 'patchq_reports', queue = q.method.queue) print "All done." print print "You might want to look at the queues and exchanges by running" print "‘rabbitmqctl list_queues’ and ‘rabbitmqctl list_exchanges’." print print "If you want to see the queue contents in more detail, then use" print "rabbitmqadmin, see:" print " https://www.rabbitmq.com/management-cli.html" print " https://stackoverflow.com/questions/10709533/is-it-possible-to-view-rabbitmq-message-contents-directly-from-the-command-line"