jmeter测试dubbo接口

本文详细介绍了如何使用jmeter对Dubbo接口进行性能测试。通过创建服务端和消费端代码,设置dubbo.properties配置,打包服务端和消费端,并将消费端jar包放入jmeter的lib/ext目录。在jmeter中新建java请求,验证脚本功能,成功实现了模拟并发调用服务提供方,确保响应数据正常。
摘要由CSDN通过智能技术生成

本文讲解jmeter测试dubbo接口的实现方式,文章以一个dubbo的接口为例子进行讲解,该dubbo接口实现的功能为:

 

  • 一:首先我们看服务端代码

代码架构为:

 

1:新建一个maven工程,pom文件为:

复制代码
 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4 
 5     <groupId>com.ustc.demo</groupId>
 6     <artifactId>dubbo-provider</artifactId>
 7     <version>0.0.1-SNAPSHOT</version>
 8     <packaging>jar</packaging>
 9 
10     <name>dubbo-provider</name>
11     <url>http://maven.apache.org</url>
12 
13     <properties>
14         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15     </properties>
16 
17     <dependencies>
18         <dependency>
19             <groupId>junit</groupId>
20             <artifactId>junit</artifactId>
21             <version>3.8.1</version>
22             <scope>test</scope>
23         </dependency>
24         <dependency>
25             <groupId>com.alibaba</groupId>
26             <artifactId>dubbo</artifactId>
27             <version>2.4.9</version>
28         </dependency>
29         <dependency>
30             <groupId>com.github.sgroschupf</groupId>
31             <artifactId>zkclient</artifactId>
32             <version>0.1</version>
33         </dependency>
34     </dependencies>
35     <build>
36         <plugins>
37             <plugin>
38                 <artifactId>maven-dependency-plugin</artifactId>
39                 <executions>
40                     <execution>
41                         <id>unpack</id>
42                         <phase>package</phase>
43                         <goals>
44                             <goal>unpack</goal>
45                         </goals>
46                         <configuration>
47                             <artifactItems>
48                                 <artifactItem>
49                                     <groupId>com.alibaba</groupId>
50                                     <artifactId>dubbo</artifactId>
51                                     <version>${project.parent.version}</version>
52                                     <outputDirectory>${project.build.directory}/dubbo</outputDirectory>
53                                     <includes>META-INF/assembly/**</includes>
54                                 </artifactItem>
55                             </artifactItems>
56                         </configuration>
57                     </execution>
58                 </executions>
59             </plugin>
60             <plugin>
61                 <artifactId>maven-assembly-plugin</artifactId>
62                 <configuration>
63                     <descriptor>src/main/assembly/assembly.xml</descriptor>
64                 </configuration>
65                 <executions>
66                     <execution>
67                         <id>make-assembly</id>
68                         <phase>package</phase>
69                         <goals>
70                             <goal>single</goal>
71                         </goals>
72                     </execution>
73                 </executions>
74             </plugin>
75         </plugins>
76     </build>
77 </project>
复制代码

2:在src/main下新建文件夹assembly,然后在assembly文件夹下新建assembly.xml文件

复制代码
 1 <assembly>
 2     <id>assembly</id>
 3     <formats>
 4         <format>tar.gz</format>
 5     </formats>
 6     <includeBaseDirectory>true</includeBaseDirectory>
 7     <fileSets>
 8         <fileSet>
 9             <directory>${project.build.directory}/dubbo/META-INF/assembly/bin
10             </directory>
11             <outputDirectory>bin</outputDirectory>
12             <fileMode>0755</fileMode>
13         </fileSet>
14         <fileSet>
15             <directory>src/main/assembly/conf</directory>
16             <outputDirectory>conf</outputDirectory>
17             <fileMode>0644</fileMode>
18         </fileSet>
19     </fileSets>
20     <dependencySets>
21         <dependencySet>
22             <outputDirectory>lib</outputDirectory>
23         </dependencySet>
24     </
Doe 发布 [V1.0.0] 前段时间排查某问题的时候,想要快速知道某些dubbo接口(三无)的响应结果,但不想启动项目(因为这些项目不是你负责的,不会部署而且超级笨重),也不想新建一个dubbo客户端项目(占地方),也不想开telnet客户端连接口(麻烦而且有限制)。所以扣了dubbo的netty模块源码,封装了个收发客户端集成一个工具,可以快速调试dubbo接口。源码地址:https://github.com/VIPJoey/doe 极简模式 普通模式 目录结构 mmc-dubbo-api 接口项目,主要用于测试。 mmc-dubbo-provider dubbo提供者项目,主要用于测试。 mmc-dubbo-doe 主项目,实现dubbo接口调试。 deploy 部署文档 功能特性 极简模式:通过dubbo提供的telnet协议收发数据。 普通模式:通过封装netty客户端收发数据。 用例模式:通过缓存数据,方便下一次操作,依赖普通模式。 增加依赖:通过调用maven命令,下载jar包和热加载到系统,主要用来分析接口方法参数,主要作用在普通模式。 依赖列表:通过分析pom文件,展示已经加载的jar包。 其它特性 springboot 整合 redis,支持spring el 表达式。 springboot 整合 thymeleaf。 springboot 整合 logback。 netty rpc 实现原理。 开发环境 jdk 1.8 maven 3.5.3 dubbo 2.6.1 lombok 1.16.20 idea 2018 windows 7 安装步骤 安装jdk 安装maven,并设置好环境变量,仓库目录。 进入mmc-dubbo-api目录,执行mvn clean install命令,省api的jar包。 进入mmc-dubbo-doe目录,执行mvn clean install 命令,在target目录生成dubbo-doe-1.0.0-RELEASE.jar 在F盘(可以任意盘)创建目录F:\app\doe 把dubbo-doe-1.0.0-RELEASE.jar拷贝到F:\app\doe 把deploy目录的所有文件拷贝到F:\app\doe 如果您电脑安装了git bash,可以在bash窗口运行 ./deploy.sh start,否则如果没有安装git bash,只能打开cmd切换到F:\app\doe目录,然后执行java -jar dubbo-doe-1.0.0-RELEASE.jar --spring.profiles.active=prd 打开浏览器,访问地址:http://localhost:9876/doe/home/index 全剧终
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值