I have a java maven project and i want to be able to test the performance of our mqtt broker using gatling. I understand that gatling directly doesn't support mqtt protocol.
I came across gatling-mqtt plugin in github. I'm not sure how i can use this plugin in my maven project. I couldn't find an existing maven plugin or dependency for this.
I have added the following dependencies in pom.xml
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
<artifactId>gatling-core</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.fusesource.mqtt-client</groupId>
<artifactId>mqtt-client</artifactId>
<version>1.12</version>
</dependency>
and the following plugins:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>performanceTests</id>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<simulationClass>simulation.Publish</simulationClass>
</configuration>
</execution>
</executions>
</plugin>
I'm trying to write a simulation very similar to this:
import io.gatling.core.Predef._
import org.fusesource.mqtt.client.QoS
import scala.concurrent.duration._
import com.github.mnogu.gatling.mqtt.Predef._
class MqttSimulation extends Simulation {
val mqttConf = mqtt
// MQTT broker
.host("tcp://localhost:1883")
val scn = scenario("MQTT Test")
.exec(mqtt("request")
// topic: "foo"
// payload: "Hello"
// QoS: AT_LEAST_ONCE
// retain: false
.publish("foo", "Hello", QoS.AT_LEAST_ONCE, retain = false))
setUp(
scn
.inject(constantUsersPerSec(10) during(90 seconds)))
.protocols(mqttConf)
}
But for writing such a scenario, I'm unable to use the mqtt object.
Error that i get is 'not found: value mqtt'
I created a jar of the gatling-mqtt project which I included in my project. I was then able to use the mqtt object.
You can create a jar by downloading sbt. In your console, from the project path run command '$sbt assembly'. This will create a jar for you.