-
Notifications
You must be signed in to change notification settings - Fork 3
/
opensuserabbit.py
executable file
·39 lines (31 loc) · 1.21 KB
/
opensuserabbit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python -u
import pika
import sys
# or amqps://suse:[email protected]
url = "amqps://opensuse:[email protected]"
if len(sys.argv) >= 2:
url = sys.argv[1]
prefix= "opensuse"
if len(sys.argv) >= 3:
prefix = sys.argv[2]
connection = pika.BlockingConnection(pika.URLParameters(url))
channel = connection.channel()
channel.exchange_declare(exchange='pubsub', type='topic',
passive=True, durable=True)
result = channel.queue_declare(exclusive=True)
queue_name = result.method.queue
channel.queue_bind(exchange='pubsub', queue=queue_name,routing_key=prefix+'.obs.request.create')
channel.queue_bind(exchange='pubsub', queue=queue_name,routing_key=prefix+'.obs.request.state_change')
#print(' [*] Waiting for logs. To exit press CTRL+C')
# opensuse.obs.request.create
# opensuse.obs.request.state_change
# opensuse.obs.request.review_wanted
# opensuse.obs.request.comment
# opensuse.obs.package.commit ... "requestid":"539138"}
def callback(ch, method, properties, body):
#if method.routing_key == "opensuse.obs.request.create":
print(body)
channel.basic_consume(callback,
queue=queue_name,
no_ack=True)
channel.start_consuming()