RocketMQ概要
在互联网企业技术架构中,MQ占据了越来越重要的地位。系统解耦、异步通信、削峰填谷、数据顺序
保证等场景中,到处都能看到MQ的身影。
而测试工程师在工作中,也经常需要和mq打交道,比如构造测试数据,触发某些业务场景,以及针对
mq的性能测试等。
RocketMQ搭建
vim docker-compose.yml
version: '3.5'
services:
rmqnamesrv:
image: rocketmqinc/rocketmq:4.4.0
container_name: rmqnamesrv
ports:
- 9876:9876
environment:
#内存分配
JAVA_OPT_EXT: "-server -Xms512m -Xmx512m"
volumes:
- ./logs:/root/logs
command: sh mqnamesrv
networks:
rmq:
aliases:
- rmqnamesrv
rmqbroker:
image: rocketmqinc/rocketmq:4.4.0
container_name: rmqbroker
depends_on:
- rmqnamesrv
ports:
- 10909:10909
- 10911:10911
volumes:
- ./logs:/root/logs
- ./store:/root/store
- broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf
command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
environment:
NAMESRV_ADDR: "rmqnamesrv:9876"
JAVA_OPT_EXT: "-server -Xms512m -Xmx512m"
networks:
rmq:
aliases:
- rmqbroker
rmqconsole:
image: styletang/rocketmq-console-ng
container_name: rocketmq-console
ports:
- 8080:8080
depends_on:
- rmqnamesrv
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/rocketmq/console/logs:/root/logs
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -
Dcom.rocketmq.sendMessageWithVIPChannel=false"
networks:
rmq:
aliases:
- rmqconsole
networks:
rmq:
name: rmq
driver: bridge
配置broker.conf
brokerName = broker-a
brokerId = 0
deleteWhen = 04 #早上4点
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH #停顿
# 如果是本地程序调用云主机 mq,这个需要设置成 云主机 IP
brokerIP1=192.168.79.145
http://ip:8080
rocketmq-jmeter
https://blog.csdn.net/Testfan_zhou/article/details/122663284
maven
<dependencies>
<!-- java jmeter依赖jar包 -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
<version>5.4.1</version>
</dependency>
</dependencies>
public class Producer {
public static void main(String[] args) throws MQClientException,RemotingException, InterruptedException, MQBrokerException {
// 1. 生产者
DefaultMQProducer producer = new DefaultMQProducer("group1");
// 2. 消费者,命名服务器
producer.setNamesrvAddr("ip:9876");
producer.start();
// 3. 发送内容:主题、标签、内容
SendResult send = producer.send(new Message("topic1", "tag1", "helloworld".getBytes()));
// 4. 打印发送结果
System.out.println(send);
// 6. 关闭生产者
producer.shutdown();
}
}
指标监控
docker run --name rocketmq-exporter --restart=always -p 5557:5557 -d
sawyerlan/rocketmq-exporter --rocketmq.config.namesrvAddr="192.168.79.145:9876"
Broker TPS/QPS的监控
- 消息积压监控
- 消费组消费监控
grafana 模板id:14612
Prometheus监控
/prometheus/rules/rocketmq.rules
标签:监控,producer,RocketMQ,conf,9876,rmqnamesrv,rocketmq,logs
From: https://blog.csdn.net/su3su3su3/article/details/137244997