本文讲解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 </