Installation
The HiveMQ MQTT Client library is available in the Maven Central repository and therefore can be setup easily in your project by using a dependency management tool like Gradle or Maven.
If you use Gradle, just include the following inside your
build.gradle
file.dependencies { implementation("com.hivemq:hivemq-mqtt-client:1.3.3") }
If you use Maven, just include the following inside your
pom.xml
file.<project> ... <dependencies> <dependency> <groupId>com.hivemq</groupId> <artifactId>hivemq-mqtt-client</artifactId> <version>1.3.3</version> </dependency> </dependencies> ... </project>
NoteYou have to set the compiler version to
1.8
or higher.<project> ... <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> ... </project>
Optional features
The HiveMQ MQTT Client provides optional features via additional modules.
Module name | Description |
---|---|
hivemq-mqtt-client-websocket | Adds dependencies for the WebSocket transport |
hivemq-mqtt-client-proxy | Adds dependencies for the proxy transport |
hivemq-mqtt-client-epoll | Adds dependencies for the native epoll socket implementation |
hivemq-mqtt-client-reactor | Reactor API for the HiveMQ MQTT Client |
If you want to use these optional features, also include the respective modules in addition to the base dependency.
dependencies { implementation("com.hivemq:hivemq-mqtt-client:1.3.3") }
dependencies { implementation("com.hivemq:hivemq-mqtt-client-websocket:1.3.3") }
For versions 1.2.x, it is necessary to use the platform keyword:
dependencies { implementation(platform("com.hivemq:hivemq-mqtt-client-websocket:1.3.3")) }
dependencies { implementation("com.hivemq:hivemq-mqtt-client-proxy:1.3.3") }
For versions 1.2.x, it is necessary to use the platform keyword:
dependencies { implementation(platform("com.hivemq:hivemq-mqtt-client-proxy:1.3.3")) }
dependencies { implementation("com.hivemq:hivemq-mqtt-client-epoll:1.3.3") }
For versions 1.2.x, it is necessary to use the platform keyword:
dependencies { implementation(platform("com.hivemq:hivemq-mqtt-client-epoll:1.3.3")) }
dependencies { implementation("com.hivemq:hivemq-mqtt-client-reactor:1.3.3") }
<project> ... <dependencies> <dependency> <groupId>com.hivemq</groupId> <artifactId>hivemq-mqtt-client</artifactId> <version>1.3.3</version> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.hivemq</groupId> <artifactId>hivemq-mqtt-client-websocket</artifactId> <version>1.3.3</version> <type>pom</type> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.hivemq</groupId> <artifactId>hivemq-mqtt-client-proxy</artifactId> <version>1.3.3</version> <type>pom</type> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.hivemq</groupId> <artifactId>hivemq-mqtt-client-epoll</artifactId> <version>1.3.3</version> <type>pom</type> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.hivemq</groupId> <artifactId>hivemq-mqtt-client-reactor</artifactId> <version>1.3.3</version> </dependency> </dependencies> ... </project>
Shaded version
If you are experiencing problems with transitive dependencies, you can try the shaded version. This version packs the transitive dependencies which are only used internal under a different package name. The shaded version includes the websocket, proxy and epoll modules. To use the shaded version just append -shaded
to the artifact name.
dependencies { implementaion("com.hivemq:hivemq-mqtt-client-shaded:1.3.3") }
<project> ... <dependencies> <dependency> <groupId>com.hivemq</groupId> <artifactId>hivemq-mqtt-client-shaded</artifactId> <version>1.3.3</version> </dependency> </dependencies> ... </project>
Snapshots
Snapshots can be obtained using JitPack.
repositories { ... maven { url "https://jitpack.io" } }
dependencies { implementation("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client:develop-SNAPSHOT") }
dependencies { implementation("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client-websocket:develop-SNAPSHOT") }
For versions 1.2.x, it is necessary to use the platform keyword:
dependencies { implementation(platform("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client-websocket:develop-SNAPSHOT")) }
dependencies { implementation("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client-proxy:develop-SNAPSHOT") }
For versions 1.2.x, it is necessary to use the platform keyword:
dependencies { implementation(platform("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client-proxy:develop-SNAPSHOT")) }
dependencies { implementation("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client-epoll:develop-SNAPSHOT") }
For versions 1.2.x, it is necessary to use the platform keyword:
dependencies { implementation(platform("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client-epoll:develop-SNAPSHOT")) }
dependencies { implementation("com.github.hivemq.hivemq-mqtt-client:hivemq-mqtt-client-reactor:develop-SNAPSHOT") }
<project> ... <repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.github.hivemq.hivemq-mqtt-client</groupId> <artifactId>hivemq-mqtt-client</artifactId> <version>develop-SNAPSHOT</version> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.github.hivemq.hivemq-mqtt-client</groupId> <artifactId>hivemq-mqtt-client-websocket</artifactId> <version>develop-SNAPSHOT</version> <type>pom</type> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.github.hivemq.hivemq-mqtt-client</groupId> <artifactId>hivemq-mqtt-client-proxy</artifactId> <version>develop-SNAPSHOT</version> <type>pom</type> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.github.hivemq.hivemq-mqtt-client</groupId> <artifactId>hivemq-mqtt-client-epoll</artifactId> <version>develop-SNAPSHOT</version> <type>pom</type> </dependency> </dependencies> ... </project>
<project> ... <dependencies> <dependency> <groupId>com.github.hivemq.hivemq-mqtt-client</groupId> <artifactId>hivemq-mqtt-client-reactor</artifactId> <version>develop-SNAPSHOT</version> </dependency> </dependencies> ... </project>
Change the artifact name to hivemq-mqtt-client-shaded
to get snapshots of the shaded version.
JitPack works for all branches and also specific commits. Just specify <branch>-SNAPSHOT
or the first 10 digits of the commit id in the version.
Building from source
The HiveMQ MQTT Client project uses Gradle to build. A gradle wrapper configuration is included, so after cloning the repository from GitHub, simply change into the directory containing the project and execute ./gradlew build
.