Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mqtt 5 client support #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions mqtt-jmeter.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="jar://$MODULE_DIR$/Download/v1.0.1/mqtt-xmeter-jar-with-dependencies.jar!/" />
<libelement value="jar://$MODULE_DIR$/Download/v1.13.0/mqtt-xmeter-1.13-jar-with-dependencies.jar!/" />
<libelement value="jar://$MODULE_DIR$/Download/v2.0.2/mqtt-xmeter-2.0.2-jar-with-dependencies.jar!/" />
<libelement value="jar://$MODULE_DIR$/Download/v2.0.2/mqtt-xmeter-fuse-2.0.2-jar-with-dependencies.jar!/" />
<libelement value="jar://$MODULE_DIR$/mqtt_jmeter/target/mqtt-xmeter-2.0.3-jar-with-dependencies.jar!/" />
<libelement value="jar://$MODULE_DIR$/mqtt_jmeter/target/mqtt-xmeter-2.0.3.jar!/" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/mqtt_jmeter/src/main/java" expected_position="1" />
</src_description>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/mqtt_jmeter/target/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/mqtt_jmeter/src/main/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="mqtt-xmeter-jar-with-dependencies.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/Download/v1.0.1/mqtt-xmeter-jar-with-dependencies.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="mqtt-xmeter-1.13-jar-with-dependencies.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/Download/v1.13.0/mqtt-xmeter-1.13-jar-with-dependencies.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="mqtt-xmeter-2.0.2-jar-with-dependencies.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/Download/v2.0.2/mqtt-xmeter-2.0.2-jar-with-dependencies.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="mqtt-xmeter-fuse-2.0.2-jar-with-dependencies.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/Download/v2.0.2/mqtt-xmeter-fuse-2.0.2-jar-with-dependencies.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="mqtt-xmeter-2.0.3-jar-with-dependencies.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/mqtt_jmeter/target/mqtt-xmeter-2.0.3-jar-with-dependencies.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="mqtt-xmeter-2.0.3.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/mqtt_jmeter/target/mqtt-xmeter-2.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
133 changes: 66 additions & 67 deletions mqtt_jmeter/pom.xml
Original file line number Diff line number Diff line change
@@ -1,74 +1,73 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.xmeter</groupId>
<artifactId>mqtt-jmeter</artifactId>
<version>2.0.2</version>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.xmeter</groupId>
<artifactId>mqtt-jmeter</artifactId>
<version>2.0.3</version>

<properties>
<jmeter-version>5.4.3</jmeter-version>
</properties>
<properties>
<jmeter-version>5.5</jmeter-version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>${jmeter-version}</version>
<scope>provided</scope>
</dependency>
<dependencies>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>${jmeter-version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
<version>${jmeter-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
<version>${jmeter-version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.fusesource.mqtt-client</groupId>
<artifactId>mqtt-client</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>com.hivemq</groupId>
<artifactId>hivemq-mqtt-client</artifactId>
<version>1.3.0</version>
</dependency>

<dependency>
<groupId>com.hivemq</groupId>
<artifactId>hivemq-mqtt-client</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>

</dependencies>
</dependencies>

<build>
<finalName>mqtt-xmeter-${project.version}</finalName>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<build>
<finalName>mqtt-xmeter-${project.version}</finalName>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
3 changes: 2 additions & 1 deletion mqtt_jmeter/src/main/java/net/xmeter/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ public interface Constants {

public static final String MQTT_VERSION_3_1_1 = "3.1.1";
public static final String MQTT_VERSION_3_1 = "3.1";
public static final String MQTT_VERSION_5 = "5.0";

public static final String SAMPLE_ON_CONDITION_OPTION1 = "specified elapsed time (ms)";
public static final String SAMPLE_ON_CONDITION_OPTION2 = "number of received messages";

public static final int MAX_CLIENT_ID_LENGTH = 23;

public static final String DEFAULT_SERVER = "127.0.0.1";
public static final String DEFAULT_MQTT_VERSION = "3.1";
public static final String DEFAULT_MQTT_VERSION = "5.0";
public static final String DEFAULT_PORT = "1883";
public static final String DEFAULT_CONN_TIME_OUT = "10";
public static final String TCP_PROTOCOL = "TCP";
Expand Down
8 changes: 5 additions & 3 deletions mqtt_jmeter/src/main/java/net/xmeter/gui/CommonConnUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class CommonConnUI implements ChangeListener, ActionListener, Constants{
private final JLabeledTextField serverAddr = new JLabeledTextField("Server name or IP:");
private final JLabeledTextField serverPort = new JLabeledTextField("Port number:", 5);
private JLabeledChoice mqttVersion = new JLabeledChoice("MQTT version:", new String[] { MQTT_VERSION_3_1, MQTT_VERSION_3_1_1 }, false, false);;
private JLabeledChoice mqttVersion = new JLabeledChoice("MQTT version:", new String[] { MQTT_VERSION_5, MQTT_VERSION_3_1, MQTT_VERSION_3_1_1 }, false, false);;
private final JLabeledTextField timeout = new JLabeledTextField("Timeout(s):", 5);

private final JLabeledTextField userNameAuth = new JLabeledTextField("User name:");
Expand Down Expand Up @@ -257,9 +257,11 @@ public void configure(AbstractMQTTSampler sampler) {
serverAddr.setText(sampler.getServer());
serverPort.setText(sampler.getPort());
if(sampler.getMqttVersion().equals(MQTT_VERSION_3_1)) {
mqttVersion.setSelectedIndex(0);
} else if(sampler.getMqttVersion().equals(MQTT_VERSION_3_1_1)) {
mqttVersion.setSelectedIndex(1);
} else if(sampler.getMqttVersion().equals(MQTT_VERSION_3_1_1)) {
mqttVersion.setSelectedIndex(2);
} else if (sampler.getMqttVersion().equals(MQTT_VERSION_5)) {
mqttVersion.setSelectedIndex(0);
}
timeout.setText(sampler.getConnTimeout());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public String getLabelResource() {

@Override
public String getStaticLabel() {
return "Efficient MQTT Connect";
return "MQTT Connect";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String getLabelResource() {

@Override
public String getStaticLabel() {
return "Efficient MQTT DisConnect";
return "MQTT DisConnect";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class EfficientConnectSampler extends AbstractMQTTSampler {
public SampleResult sample(Entry entry) {
lock = new Object();
SampleResult result = new SampleResult();
result.setSampleLabel(getLabelPrefix() + getName());
result.setSampleLabel(getName());
result.setSuccessful(true);

JMeterVariables vars = JMeterContextService.getContext().getVariables();
Expand Down Expand Up @@ -75,7 +75,7 @@ public SampleResult sample(Entry entry) {
} else {
clientId = getConnPrefix();
if (clientId != null && !clientId.isEmpty()) {
clientId += "-xmeter-suffix-" + i;
clientId += "-xmeter-suffix-" + i + JMeterContextService.getContext().getThreadNum();
}
}

Expand All @@ -96,6 +96,8 @@ public SampleResult sample(Entry entry) {
suc = handleSubscription(connection);
}
if (suc) {
vars.putObject("conn", connection); // save connection object as thread local variable !!
vars.putObject("clientId", client.getClientId()); //save client id as thread local variable
subResult.setSuccessful(true);
subResult.setResponseData("Successful.".getBytes());
subResult.setResponseMessage(MessageFormat.format("Connection {0} established successfully.", connection));
Expand Down Expand Up @@ -129,6 +131,7 @@ public SampleResult sample(Entry entry) {
}
if (!connections.isEmpty()) {
vars.putObject("conns", connections);
logger.info(MessageFormat.format("Connections created. Count={0}", connections.size()));
}
result.setSampleCount(totalSampleCount);
if (result.getEndTime() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class EfficientDisConnectSampler extends AbstractMQTTSampler {
@Override
public SampleResult sample(Entry entry) {
SampleResult result = new SampleResult();
result.setSampleLabel(getLabelPrefix() + getName());
result.setSampleLabel(getName());
result.setSuccessful(true);

JMeterVariables vars = JMeterContextService.getContext().getVariables();
Expand Down
Loading