Docker installation use can refer to the previous article docker installation and Nginx mapping configuration

The RabbitMq instructions

RabbitMQ is open source message broker software (also known as message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). RabbitMQ servers are written in the Erlang language, while clustering and failover are built on top of the open telecom platform framework. All major programming languages have client libraries that communicate with proxy interfaces. –[Wikipedia]

Use the RabbitMq

RabbitMq is installed in docker

  • Pull the mirror
docker pull rabbitmq:management
Copy the code
  • Start the
docker run -d --name docker_rabbitmq \
-p 5671:5671 -p 5672:5672 -p 4369:4369 \
-p 15671:15671 -p 15672:15672 -p 25672:25672 \
rabbitmq:management
Copy the code
  • The port that

4369: Erlang found port

5672: AMQP client port

15672: HTTP management interface port

25672: clustering internal communication port of the server

  • Automatic restart
docker update docker_rabbitmq --restart=always
Copy the code
  • See the log
docker logs -f [container/id]
Copy the code
  • Enter the
docker exec -it docker_rabbitmq bash
Copy the code
  • Adding a user (default guest)
rabbitmqctl add_user [username] [password]
Copy the code
  • authorization
rabbitmqctl set_permissions -p / root ". *" ". *" ". *"
Copy the code
  • role
rabbitmqctl set_user_tags root administrator
Copy the code
  • To view the user
rabbitmqctl list_users
Copy the code

Directions for use

Logging In to the Management Page

  • Domain name + port, login user. The default port is 15672, the default user name is guest, and the default password is guest. The actual situation depends on the Docker port mapping and configuration

Common publish-subscribe patterns

direct

Features: Point-to-point message sending

Example:

  • Creating a Direct switch Add a new exchange: direct-exchange01

  • Create a queue Add a new queue: queue01,queue02

  • Switch and queue Bindings

  • Test the Publish the message

  • Note: ACK indicates that a message is received and consumed, whereas NACK indicates that the message is still in the queue

fanout

Features: All queues can receive messages regardless of rountkey

topic

Matches all matching queues based on the key name

  • Switch: topic-exchange01
  • Binding queue
    • queue01: prekey01.#All queues with the prefix prekey01 receive messages with # indicating that one or more words are matched and * indicating that one is matched
    • queue02: #.sufkey02All queues with the suffix sufkey02 receive messages
    • queue03: #.sufkey03All queues with the suffix sufkey03 receive messages
  • test

Only Queue01 received the message

Only Queue02 received

Queue01, Queue03 Received


Please refer to the official documentation for more operations