Implementation of rocketmq message sending based on JMeter

S-Gavin 2021-01-14 13:58:18
implementation rocketmq message sending based


In the Internet enterprise technology architecture ,MQ It's getting more and more important . system decoupling 、 asynchronous communication 、 Peak shaving and valley filling 、 Data order guarantee and so on , You can see... Everywhere MQ The figure of .

And the test engineer at work , And often need to talk to mq Dealing with , For example, constructing test data , Trigger some business scenarios , And aiming at mq Performance test, etc .

At present, it is well-known in the industry mq The products are kafka、rabbitmq、rocketmq etc. . Today I'm going to talk about how to use Jmeter Come to rocketmq Send a message , Realize to mq Performance test of sending message function .

Let's start with a brief introduction Rocketmq

RocketMQ It's a distributed 、 Message middleware of queue model , It is a professional message middleware independently developed by Alibaba group , After many times of tmall double 11 massive news test . It has been donated to Apache The foundation , And in 2016 year 11 Month be Apache Incubation projects .

1、MQ Basic concepts

Message: news , The carrier of information transmission in message queue

Topic: Message topic , First level message type , adopt Topic Categorize messages

Tag: Message tags , Secondary message type , Used to further differentiate a Topic Next message classification

Producer: Message producer , Also known as the publisher of the message , Responsible for producing and sending messages

Consumer: Message consumer , Also known as a message subscriber , Responsible for receiving and consuming messages

2、RocketMQ Of 4 A component

Namely nameserver、broker、producer and consumer

Broker: The core module of cluster , Mainly responsible for Topic Message store 、 Consumer's consumption point management ( Consumption progress )Producer: Message producer , Every producer has one ID( Number )

nameserver: Store all of the current cluster Brokers Information 、Topic Follow Broker Correspondence of

Consumer: Message consumer , Each subscriber also has one ID( Number )

3、MQ Messaging model

After understanding the above concepts , Let's write Jmeter Script .

stay idea Create a Java engineering , And introduce Rocketmq and Jmeter The dependency package of , Let's write one demo Script .Rocketmq The message sending code is very simple , Just a few lines of code , The code is as follows :

Run script , You can see the printed results “SEND_OK” word , Indicates that the message was sent successfully .

Log in to rocketmq Console page , You can search for the message you just sent .

  up to now , The test script has been debugged , Just convert the script to Jmeter The script can be . It can be divided into the following steps :

1、  Create a test class , Realization Jmeter Of JavaSamplerClient Interface , Need to implement... In the interface 4 A way , Respectively :

setupTest: Script initialization operation , Each thread executes when it starts , And only once

runTest:Jmeter Thread loop execution method

teardownTest:Jmeter The ending method , Execute at the end of each thread , And only once

getDefaultParameters: Need to be exposed to Jmeter Parameters in the interface , For the time being, we do not need

According to the characteristics of the four methods , The corresponding mq Code operations in different ways , Detailed explanation can be seen in the comment code as follows :

 

 2、  take Java Scripts and their dependent packages are exported as jar package , Then put jmeter Of lib/ext Under the table of contents

 

 3、  open Jmeter, newly build “Java request ”, Select the script class you just wrote

 

  That's it , One is based on Jmeter Sending of MQ The message script is done , If you want to do a pressure test , stay Jmeter Configure the number of threads and duration to start the pressure measurement .

 

版权声明
本文为[S-Gavin]所创,转载请带上原文链接,感谢
https://javamana.com/2021/01/20210114111702427y.html

  1. Spring boot static resource configuration principle (step by step source analysis, detailed and easy to understand)
  2. 400万Docker镜像中,51%的镜像存在高危漏洞
  3. Head first design pattern -- 10. Iterator pattern
  4. A few pictures, take down the HTTPS
  5. Simple use of pyecharts module
  6. [azure redis cache] discussion on the functionality of azure redis
  7. Installation of SVN under Linux
  8. Sorting out knowledge points of MySQL Cluster
  9. rocketmq-cpp-client Visual Studio 2019 编译
  10. rocketmq-cpp-client Visual Studio 2019 编译
  11. RBAC authorization mode of k8s
  12. Remember to use it once Asp.Net The development process of core webapi 5.0 + dapper + MySQL + redis + docker
  13. Java Concurrent Programming points
  14. Explain Java I / O flow in detail
  15. Linux system builds springboot project environment and deploys it
  16. Easy to understand JS object-oriented, by the way understand prototype and__ proto__
  17. Summary of java basic knowledge
  18. . net cloud native architect training camp (module 2 basic consolidation rabbitmq mastransit detailed explanation) - learning notes
  19. The architecture of MySQL
  20. MySQL security management, database maintenance and performance improvement
  21. Redis basic command
  22. Summary of MySQL articles
  23. 2、 Create k8s cluster in 5 seconds
  24. data自定义属性在jQuery中的用法
  25. Linux常见解压缩
  26. Detailed explanation of HBase basic principle
  27. 1、 Why and how to learn k8s
  28. Java advanced (29) -- HashMap set
  29. java中大文件上传
  30. Weblogic 2017-3248 analysis of Java Security
  31. Kubernetes official java client 8: fluent style
  32. Explain the function of thread pool and how to use it in Java
  33. Programming software tutorial video Encyclopedia: C + + / Java / Python / assembly / easy language (with tutorial)
  34. Description of dependency problem after javacv is updated to 1.5. X and how to reduce the size of dependency package
  35. Java reflection & dynamic agent
  36. Building Apache 2.4 + php7 + mysql8 in centos7 environment
  37. Summary of Java multithreading (1)
  38. Oracle AWR report generation
  39. Four magic functions of mybatis, don't step on the pit!
  40. A 16-year-old high school student successfully transplanted Linux to iPhone and posted a detailed guide
  41. Centos7 one click installation of JDK1.8 shell script
  42. Mounting of file system in Linux (centos7)
  43. How does serverless deal with the resource supply demand of k8s in the offline scenario
  44. Detailed explanation of HBase basic principle
  45. Spring security oauth2.0 authentication and authorization 4: distributed system authentication and authorization
  46. Redis performance Part 5 redis buffer
  47. JavaScript this keyword
  48. Summary of Java multithreading (3)
  49. Sentry(v20.12.1) K8S 云原生架构探索, SENTRY FOR JAVASCRIPT 手动捕获事件基本用法
  50. Sentry(v20.12.1) K8S 云原生架构探索, SENTRY FOR JAVASCRIPT 手动捕获事件基本用法
  51. (10) Spring from the beginning to the end
  52. Summary of Java multithreading (2)
  53. Spring source notes! From the introduction to the source code, let you really understand the source code
  54. A stormy sunny day
  55. Zookeeper (curator), the implementation of distributed lock
  56. Show the sky! Tencent T4's core Java Dictionary (framework + principle + Notes + map)
  57. Spring boot project, how to gracefully replace the blank value in the interface parameter with null value?
  58. Spring boot project, how to gracefully replace the blank value in the interface parameter with null value?
  59. docker+mysql集群+读写分离+mycat管理+垂直分库+负载均衡
  60. docker+mysql集群+读写分离+mycat管理+垂直分库+负载均衡