2 # -*- coding: utf-8 -*-
4 # Create all the exchanges, queues and other objects in RabbitMQ.
6 # You must configure the hostname of the RabbitMQ server in
9 # You only have to run this once, but you must run it before running
10 # any other part of patchq.
12 # All RabbitMQ objects created are prefixed by ‘patchq_...’. To
13 # reverse the effects of this script, delete those objects (using
14 # rabbitmqadmin or similar).
19 connection = pika.BlockingConnection(pika.ConnectionParameters(
20 host = config.mq_server))
21 channel = connection.channel()
23 # Create the input exchange and queue which take raw emails in any
24 # order and queues them so they can be later threaded and ordered (by
26 channel.exchange_declare(exchange = 'patchq_input',
27 exchange_type = 'fanout',
29 q = channel.queue_declare(queue = 'patchq_input',
31 channel.queue_bind(exchange = 'patchq_input',
32 queue = q.method.queue)
34 # Create the exchange and queue(s) which take fully threaded and
35 # ordered patch series and passes them to the tests.
36 channel.exchange_declare (exchange = 'patchq_thread',
37 exchange_type = 'fanout',
39 for t in config.tests:
40 qname = "patchq_test_%s" % t
41 q = channel.queue_declare(queue = qname,
43 channel.queue_bind(exchange = 'patchq_thread',
44 queue = q.method.queue)
46 # Create the email results queue.
47 channel.exchange_declare(exchange = 'patchq_reports',
48 exchange_type = 'fanout',
50 q = channel.queue_declare(queue = 'patchq_reports',
52 channel.queue_bind(exchange = 'patchq_reports',
53 queue = q.method.queue)
57 print "You might want to look at the queues and exchanges by running"
58 print "‘rabbitmqctl list_queues’ and ‘rabbitmqctl list_exchanges’."
60 print "If you want to see the queue contents in more detail, then use"
61 print "rabbitmqadmin, see:"
62 print " https://www.rabbitmq.com/management-cli.html"
63 print " https://stackoverflow.com/questions/10709533/is-it-possible-to-view-rabbitmq-message-contents-directly-from-the-command-line"