作者:黄自安_725 | 来源:互联网 | 2023-10-17 18:53
篇首语:本文由编程笔记#小编为大家整理,主要介绍了Jmeter对RabbitMQ压力测试相关的知识,希望对你有一定的参考价值。
Jmeter原生不支持对MQ的消息压测,需要安装AMQP插件
https://github.com/jlavallee/JMeter-Rabbit-AMQP
一.编译JMeter-Rabbit-AMQP插件
1.电脑安装jdk 1.8 (https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html)
2.电脑安装apache-ant (https://dlcdn.apache.org//ant/binaries/apache-ant-1.9.16-bin.zip)
3.下载 RabbitMQ客户端插件amqp-client-3.4.4.jar(https://repo1.maven.org/maven2/com/rabbitmq/amqp-client/3.4.4/amqp-client-3.4.4.jar)到源码目录
3.修改配置文件
(1)修改源码里的build.xml,http改成https
(2)修改build.xml里面ivy.install.version,2.3.0改成2.5.0
4.打包
直接在所在目录,执行ant命令即可
5.复制插件到jmeter目录
(1)把上面下载的amqp-client-3.4.4.jar复制到jmeter安装目录的lib\\ext目录下
(2)把源码目录下target\\dist目录下的JMeterAMQP.jar也复制到lib\\ext目录下
6.启动jmeter的时候就出现了
二.压力测试
1.将文件的内容保存到一个rabbitmq.jmx
version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.3">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="RPC Test Plan" enabled="true">
<stringProp name="TestPlan.comments">stringProp>
<boolProp name="TestPlan.functional_mode">falseboolProp>
<boolProp name="TestPlan.serialize_threadgroups">falseboolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
elementProp>
<stringProp name="TestPlan.user_define_classpath">stringProp>
TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="rabbitmq" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">stopteststringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">falseboolProp>
<intProp name="LoopController.loops">-1intProp>
elementProp>
<stringProp name="ThreadGroup.num_threads">8stringProp>
<stringProp name="ThreadGroup.ramp_time">15stringProp>
<longProp name="ThreadGroup.start_time">1361373100000longProp>
<longProp name="ThreadGroup.end_time">1361373100000longProp>
<boolProp name="ThreadGroup.scheduler">trueboolProp>
<stringProp name="ThreadGroup.duration">60stringProp>
<stringProp name="ThreadGroup.delay">stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">trueboolProp>
ThreadGroup>
<hashTree>
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Reply-To Queue Name" enabled="true">
<stringProp name="maximumValue">999999999stringProp>
<stringProp name="minimumValue">1stringProp>
<stringProp name="outputFormat">000000000stringProp>
<boolProp name="perThread">falseboolProp>
<stringProp name="randomSeed">stringProp>
<stringProp name="variableName">replyToQueuestringProp>
RandomVariableConfig>
<hashTree/>
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Unique ID" enabled="true">
<stringProp name="variableName">uniqueIdstringProp>
<stringProp name="outputFormat">0000000stringProp>
<stringProp name="minimumValue">1stringProp>
<stringProp name="maximumValue">9999999stringProp>
<stringProp name="randomSeed">3499272stringProp
var cpro_id = "u6885494";