RabbitMQ
Jump to navigation
Jump to search
Useful commands
rabbitmqctl list_exchanges --formatter pretty_table
rabbitmqctl list_queues --formatter pretty_table
curl --request GET --user guest:guest --url http://localhost:15672/api/queues | jq
apt-get update && apt-get install -y python3-pika cat > attach_exchange.py << 'EOF' #!/usr/bin/env python3 import pika import sys if not len(sys.argv) == 2: sys.stderr.write("Usage: %s [exchange_name]\n" % sys.argv[0]) sys.exit(1) exchange_name=sys.argv[1] connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.exchange_declare(exchange=exchange_name, exchange_type='topic', durable=True) result = channel.queue_declare('', exclusive=True) queue_name = result.method.queue #binding_keys = sys.argv[1:] #if not binding_keys: # sys.stderr.write("Usage: %s [binding_key]...\n" % sys.argv[0]) # sys.exit(1) # #for binding_key in binding_keys: # channel.queue_bind( # exchange='ExampleConnector', queue=queue_name, routing_key=binding_key) channel.queue_bind(exchange=exchange_name, queue=queue_name, routing_key='#') print(' [*] Waiting for logs. To exit press CTRL+C') def callback(ch, method, properties, body): print(" [x] %r:%r" % (method.routing_key, body)) channel.basic_consume( queue=queue_name, on_message_callback=callback, auto_ack=True) channel.start_consuming() EOF chmod 755 attach_exchange.py