整个工具的代码都在Gitee或者Github地址内
gitee:solomon-parent: 这个项目主要是总结了工作上遇到的问题以及学习一些框架用于整合例如:rabbitMq、reids、Mqtt、S3协议的文件服务器、mongodb
1.新增data文件夹
2.新增docker-compose.yml文件
version: '3.8'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
ports:
- "15672:15672"
- "5672:5672"
volumes:
- ./data:/usr/etc/rabbitmq/data
- /etc/localtime:/etc/localtime # 容器与宿主机时间同步
- ./plugins/rabbitmq_delayed_message_exchange-3.13.0.ez:/plugins/rabbitmq_delayed_message_exchange-3.13.0.ez
- ./init.sh:/usr/local/bin/init.sh
command: ["/bin/bash", "-c", "chmod +x /usr/local/bin/init.sh && /usr/local/bin/init.sh"]
restart: always
3.去github下载延迟插件
去这个地址下载rabbitmq的延迟队列插件https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/v3.13.0/rabbitmq_delayed_message_exchange-3.13.0.ez
下载好后将插件放入plugins文件夹内
4.新增init.sh脚本
#!/bin/bash
# 启动 RabbitMQ 服务
docker-entrypoint.sh rabbitmq-server &
# 等待 RabbitMQ 启动
echo "等待 RabbitMQ 服务启动"
sleep 20 # 等待时间可以根据实际情况调整
# 启用延迟消息插件
echo "启用延迟消息插件"
rabbitmq-plugins enable rabbitmq_delayed_message_exchange
# 保持前台运行,避免容器退出
wait