RabbitMQ creating queues and bindings from command line

后端 未结 11 1606
时光取名叫无心
时光取名叫无心 2020-12-12 15:25

If I have RabbitMQ installed on my machine, is there a way to create a message queue from the command line and bind it to a certain exchange without using a client?

I

11条回答
  •  心在旅途
    2020-12-12 16:16

    Here is a more minimal Python example, taken from the RabbitMQ Python tutorial.

    First, install pika:

    sudo easy_install pika
    # (or use pip)
    

    This is all you need to send a message to localhost:

    import pika
    
    connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
    channel = connection.channel()
    
    channel.queue_declare(queue='test-queue')
    channel.basic_publish(exchange='', routing_key='test-queue', body='Hello World!')
    

提交回复
热议问题