编辑 docker-compose.yaml
version: '3.8'
services:
namesrv:
image: apache/rocketmq:4.8.0
container_name: rmqnamesrv
ports:
- 9876:9876
networks:
- rocketmq
command: sh mqnamesrv
broker:
image: apache/rocketmq:4.8.0
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
- 10912:10912
environment:
- NAMESRV_ADDR=rmqnamesrv:9876
volumes:
- ./broker.conf:/home/rocketmq/rocketmq-4.8.0/conf/broker.conf
depends_on:
- namesrv
networks:
- rocketmq
command: sh mqbroker -c /home/rocketmq/rocketmq-4.8.0/conf/broker.conf
rocketmq-dashboard:
image: apacherocketmq/rocketmq-dashboard
container_name: rocketmq-dashboard
ports:
- 8087:8080
networks:
- rocketmq
environment:
- JAVA_OPTS=-Drocketmq.namesrv.addr=rmqnamesrv:9876
depends_on:
- namesrv
- broker
networks:
rocketmq:
driver: bridg
测试发送消息
$ docker exec -it rmqbroker bash
$ sh tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= ...
$ sh tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt...