基础篇
阿里巴巴开源 参考kafka实现
应用场景:应用解耦,流量削峰,数据分发
源码地址:https://github.com/apache/rocketmq
中文文档:https://github.com/apache/rocketmq/tree/master/docs/cn
商业版:https://www.aliyun.com/product/rocketmq
官网翻译:http://www.itmuch.com/books/rocketmq/
FAQ:http://rocketmq.apache.org/docs/faq/
RocketMQ常用管理命令:https://blog.csdn.net/gwd1154978352/article/details/80829534
RocketMQ默认配置:https://www.cnblogs.com/jice/p/11981107.html
Linux基础搭建
下载地址:https://rocketmq.apache.org/dowloading/releases/
单机版broker搭建
创建文件目录: mkdir -p /home/rocketmq/store/broker-a /home/rocketmq/store/broker-a/consumequeue /home/rocketmq/store/broker-a/commitlog /home/rocketmq/store/broker-a/index /home/rocketmq/broker-a/logs unzip rocketmq-all-4.8.0-bin-release.zip mv rocketmq-all-4.8.0-bin-release rocketmq-4.8.0
修改配置文件:
vim broker.conf #Broker 对外服务的监听端口 listenPort=10911 ##是否允许 Broker 自动创建Topic,建议线下开启,线上关闭 autoCreateTopicEnable=true ##是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭 autoCreateSubscriptionGroup=true ##nameServer地址,分号分割 namesrvAddr=localhost:9876 ##存储路径 storePathRootDir=/home/rocketmq/store/broker-a ##commitLog 存储路径 storePathCommitLog=/home/rocketmq/store/broker-a/commitlog ##消费队列存储路径存储路径 storePathConsumeQueue=/home/rocketmq/store/broker-a/consumequeue ##消息索引存储路径 storePathIndex=/home/rocketmq/store/broker-a/index ##checkpoint 文件存储路径 storeCheckpoint=/home/rocketmq/store/broker-a/checkpoint ##abort 文件存储路径 abortFile=/home/rocketmq/store/broker-a/abort 启动: 修改bin目录下的runbroker.sh 和 runserver.sh 文件 比如把8g 4g 改成512m, 4g 2g改成256m cd /home/rocketmq/rocketmq-4.8.0/bin nohup sh mqnamesrv & nohup sh mqbroker -c /home/rocketmq/rocketmq-4.8.0/conf/broker.conf & 查看日志: tail -f ~/logs/rocketmqlogs/namesrv.log tail -f ~/logs/rocketmqlogs/broker.log 关闭服务: cd /home/rocketmq/rocketmq-4.8.0/bin/ sh mqshutdown namesrv sh mqshutdown broker
rocketmq-console搭建
cd /home/rocketmq/rocketmq-externals-master/rocketmq-console/src/main/resources cd /home/rocketmq/rocketmq-externals-master/rocketmq-console mvn clean package -Dmaven.test.skip=true mvn clean package -Dcheckstyle.skip=true cd target nohup java -jar rocketmq-console-ng-2.0.0.jar &
其他信息
Producer:消息生产者
Producer Group:消息生产者组,发送同类消息的一个消息生产组
Consumer:消费者
Consumer Group:消费同个消息的多个实例
Tag:标签,子主题(二级分类),用于区分同一个主题下的不同业务的消息
Topic:主题
Message:消息
Broker:MQ程序,接收生产的消息,提供给消费者消费的程序
Name Server:给生产和消费者提供路由信息,提供轻量级的服务发现和路由