• notice
  • Congratulations on the launch of the Sought Tech site

docker install RabbitMQ

Install RabbitMQ

Reference documentation

pull image

docker pull docker.io/rabbitmq:3.8-management

run the container

docker run --name rabbitmq -d -p 15672:15672 -p 5672:5672 4b23cfb64730


ip:15672 Default account password guest/guest

Default port: 15672 for web management and 5672 for AMQP port (used when connecting to mq)

Install composer dependencies

php composer.phar require php-amqplib/php-amqplib

Development steps

  • Admin page to create vhost (virtual machine)

  • And create a user to bind the vhost (the user can operate this vhost)

  • Create exchange (exchange) and bind vhost

  • Create a queue, bind the exchange and specify the routekey (routekey messages sent to this exchange will be distributed to this queue)

  • The producer connects to the vhost and pushes the message to the exchange and specifies the routekey

  • The consumer connects to the vhost and specifies a queue for consumption (no need to specify routekey and exchange)

exchange distribution mode


The routekey of the producer message must exactly match the routekey bound to the queue before it is allocated to the queue


The routekey of the producer message will be assigned to the queue as long as it conforms to the routekey wildcard rules bound to the queue

Wildcard settings

  • Routingkey generally consists of one or more monograms, and multiple words are separated by ".", for example: item.insert
    wildcard rule: # matches one or more words, * matches no more than no less and exactly 1 Words, for example: item.# can match item.insert.abc or item.insert, item.* can only match item.insert


Technical otaku

Sought technology together

Related Topic


Leave a Reply