catalogue
concept
Rabbit is a message oriented middleware that can accept and forward messages. You can regard it as an express site. When you want to send a package, you put your package in the express station, and the courier will eventually send your express to the recipient. According to this logic, RabbitMQ is an express station, and a courier will deliver the express for you. The difference between RabbitMQ and express station is that it does not handle express, but accepts, stores and forwards messages!
Four concepts
Producer
The program that generates data and sends messages is the producer!
Switch
Switch is a very important part of RabbitMQ. On the one hand, it accepts messages from producers, on the other hand, it pushes messages to queues. The switch must know exactly how to handle the messages it receives, whether to push these messages to a specific queue or multiple queues, or discard the messages, which depends on the switch type
Queue
Queue is a data structure used internally by RabbitMQ. Although messages flow through RabbitMQ and applications, they can only be stored in the queue. The queue is only constrained by the memory and disk limitations of the host. It is essentially a large message buffer. Many producers can send messages to a queue, and many consumers can try to accept messages from a queue. This is how we use queues.
Consumer
Consumption and acceptance have similar meanings. Most of the time, consumers are a program waiting to receive messages. Please note that producers, consumers and message middleware are often not on the same machine. The same application can be both producers and consumers.
Six modes
Simple mode (Hello World!) Work queues, publish / subscribe
, routing, topics, publisher confirmations
working principle
Download
CentOS7 and rabbit mq3 are used this time Version 8.8
1. Enter RabbitMQ and click Get Started
2. View the Erlang version support required by the current RabbitMq
3. Download Erlang( Erlang and Elixir Packages Download - Erlang Solutions)
4. Download RabbitMQ
Find release Journal
Find the corresponding version and click release notes
Go down to Assets and click download
Installation
1. Upload the corresponding rpm package to linux. FinalShell is used this time
2. Installation documents
-- 1,install Erlang rpm -ivh --force --nodeps esl-erlang_23.0-1_centos_7_amd64.rpm -- 2,install socat yum install socat -y -- 3,install RabbitMQ rpm -ivh rabbitmq-server-3.8.8-1.el7.noarch.rpm -- 4,Configure startup and self startup chkconfig rabbitmq-server on -- 5,start-up RabbitMQ /sbin/service rabbitmq-server start
3. Install the web management interface
-- install web Interface rabbitmq-plugins enable rabbitmq_management -- Check whether the port is open firewall-cmd --zone=public --list-ports -- Open 15672 port firewall-cmd --zone=public --add-port=15672/tcp --permanent -- Effective immediately firewall-cmd --reload
4. Access the web management interface (localhost:15672)
5. Add an account
-- 1,Add user rabbitmqctl add_user admin admin -- 2,Set user assigned operation permissions - administrator You can log in to the console and view all information rabbitmq Manage - monitoring The monitor logs in to the console to view all information - policymaker The policy maker logs in to the console and specifies the policy - managment General administrator login console rabbitmqctl set_user_tags admin administrator -- 3,Change Password rabbitmqctl change_password Username NewPassword -- 4,View user list rabbitmqctl list_users
6. Login
Docker installing RabbitMQ
1. Install docker
-- 1,Remove old version yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine -- 2,Install the installation package that needs to be installed yum install -y yum-utils -- 3,Set up mirror warehouse yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -- 4,to update yum Index of the package yum makecache fast -- 5,install docker Related content yum install docker-ce docker-ce-cli containerd.io -- 6,start-up docker systemctl status docker -- 7,see docker Is the installation successful docker version
2. Basic download methods provided on the official website( Downloading and Installing RabbitMQ — RabbitMQ)
- 1,3.9 Download of the latest version docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9-management - 2,3.8 Under version docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.8-management
3. Details of docker's official website( Docker Hub)
docker run -d --hostname my-rabbit --name some-rabbit -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3-management
4. View the graphical interface