RabbitMQ 消息确认 basicReject / basicNack / basicRecover 区别
channel.basicReject(deliveryTag, true);basic.reject方法拒绝deliveryTag对应的消息，第二个参数是否requeue，true则重新入队列，否则丢弃或者进入死信队列。该方法reject后，该消费者还是会消费到该条被reject的消息。channel.basicNack(deliveryTag, false, true);basic.nack方法为不确认deliveryTag对应的消息，第二个参数是否应用于多消息，第三个参数是否requeue，与basic.reject区别就是同时支持多个消息，可以nack该消费者先前接收未ack的所有消息。nack后的消息也会被自己消费到。channel.basicRecover(true);basic.recover是否恢复消息到队列，参数是是否requeue，true则重新入队列，并且尽可能的将之前recover的消息投递给其他消费者消费，而不是自己再次消费。false则消息会重新被投递给自己。
1、安装erlangyum -y install erlang2、下载安装包wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.11.9/rabbitmq-server-3.11.9-1.el8.noarch.rpm3、安装rpm包yum install -y rabbitmq-server-3.11.9-1.el8.noarch.rpm
RabbitMQ在命令行添加用户密码并设置权限
RabbitMQ在命令行添加用户密码并设置权限rabbitmqctl add_user mqadmin mqadmin rabbitmqctl set_user_tags mqadmin administrator rabbitmqctl set_permissions -p "/" mqadmin ".*" ".*" ".*"
CentOS7 Docker 容器启动报错 WARNING: IPv4 forwarding is disabled. Networking will not work
解决办法：# vi /etc/sysctl.conf或者# vi /usr/lib/sysctl.d/00-system.conf添加如下代码：net.ipv4.ip_forward=1重启network服务# systemctl restart network查看是否修改成功# sysctl net.ipv4.ip_forward如果返回为net.ipv4.ip_forward = 1则表示成功了这时，重启容器即可。另外还可以通过run时加-p 参数指定IP的方式来解决，比如 -p 0.0.0.0:9999:9999（指定ip就按ipv4来，否则默认全部是ipv6的。）
docker run -dit --name rabbitmq --net=bridge -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin123 -p 15672:15672 -p 5672:5672 rabbitmq:3.8-management# for RabbitMQ 3.9, the latest series docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9-management# for RabbitMQ 3.8, # 3.8.x support timeline: https://www.rabbitmq.com/versions.html docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.8-managementDocker前台运行RabbitMQ：docker run -it --rm --name rabbitmq -e RABBITMQ_DEFAULT_USER=mqadmin -e RABBITMQ_DEFAULT_PASS=mqadmin123 -p 5672:5672 -p 15672:15672 rabbitmq:3-managementDocker后台运行RabbitMQ：docker run -d --name rabbitmq --restart=always -e RABBITMQ_DEFAULT_USER=mqadmin -e RABBITMQ_DEFAULT_PASS=mqadmin123 -p 5672:5672 -p 15672:15672 rabbitmq:3-management详细参数：https://registry.hub.docker.com/_/rabbitmq/另参见《CentOS7 YUM系统部署RabbitMQ》
一、安装Erlangrpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/Packages/e/epel-release-7-14.noarch.rpm yum -y install erlang检查是否安装好：[root@localhost /]# erl Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]二、安装RabbitMQ（1）下载安装包，可以去官网看下最新包https://github.com/rabbitmq/rabbitmq-server/tagswget https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_6_15/rabbitmq-server-3.6.15-1.el7.noarch.rpm（2）安装rpm --import https://www.rabbitmq.com/rabbitmq-signing-key-public.asc rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc yum install -y rabbitmq-server-3.6.15-1.el7.noarch.rpm三、启动RabbitMQsystemctl start rabbitmq-server.service systemctl enable rabbitmq-server.service chkconfig rabbitmq-server on /sbin/service rabbitmq-server start # 启用web管理插件 rabbitmq-plugins enable rabbitmq_management四、打开对应端口firewall-cmd --permanent --zone=public --add-port=5672/tcp firewall-cmd --permanent --zone=public --add-port=15672/tcp firewall-cmd --reload firewall-cmd --list-ports五、增加用户rabbitmqctl add_user admin admin123 rabbitmqctl set_user_tags admin administrator # 修改密码 rabbitmqctl change_password admin admin12345六、安装pikawget https://bootstrap.pypa.io/get-pip.py python get-pip.py pip install pika《Docker运行RabbitMQ》《RabbitMQ手册之rabbitmqctl》