HiveMQ CE is a Java-based open source MQTT broker that fully supports MQTT 3.x and MQTT 5.
HiveMQ CE is the foundation of the HiveMQ enterprise-connectivity and messaging platform and implements all MQTT features. This project is the technical core of many large MQTT deployments and is now available as open source software under the Apache 2 license.
Web Site: https://www.hivemq.com/
Documentation: https://github.com/hivemq/hivemq-community-edition/wiki
Community Forum: https://community.hivemq.com/
Contribution Guidelines: Contributing.adoc
License: The source files in this repository are made available under the Apache License Version 2.0.
All MQTT 3.1, 3.1.1 and MQTT 5.0 features
MQTT over TCP, TLS, WebSocket and Secure WebSocket transport
Java Extension SDK for:
Authentication
Authorization
Client Initializers
MQTT Packet Interceptors
Interacting with Publishes, Retained Messages, Clients and Subscriptions
Running on Windows, Linux and MacOS (Linux is recommended)
Embedded Mode
HiveMQ CE is compatible with all MQTT 3 and MQTT 5 clients, including Eclipse Paho and HiveMQ MQTT Client.
The documentation for the HiveMQ CE can be found here.
MQTT Resources
The ideal place for questions or discussions about the HiveMQ Community Edition is our brand new HiveMQ Community Forum.
Download the latest HiveMQ CE binary package.
Unzip the package.
Run the run.sh (Linux/OSX) or run.bat (Windows) in the bin folder of the package.
cd hivemq-ce-<version>
./bin/run.sh
You can now connect MQTT clients to <ip address>:1883
.
Caution
|
If you want to connect devices on external networks to HiveMQ CE, please make sure your server is reachable from those networks and the required ports (default: 1883) are accessible through your firewall. |
Just in time builds for current branches on this repository and for specific commits are available here.
All releases as well as the current state of the master
branch are available in the hivemq/hivemq-ce repository on DockerHub.
To execute this image, simply run the following command:
docker run --name hivemq-ce -d -p 1883:1883 hivemq/hivemq-ce
To change the default log level you can set the environment variable HIVEMQ_LOG_LEVEL
when running the container:
docker run --name hivemq-ce -e HIVEMQ_LOG_LEVEL=INFO -d -p 1883:1883 hivemq/hivemq-ce
At least Java version 11 is required to build and run HiveMQ CE.
If you are in doubt, you can check the installed Java version by entering java -version
on your command line.
Check out the git repository and build the binary package.
git clone https://github.com/hivemq/hivemq-community-edition.git
cd hivemq-community-edition
./gradlew clean packaging
The package hivemq-ce-<version>.zip
is created in the sub-folder build/zip/
.
Check out the git repository and build the Docker image.
git clone https://github.com/hivemq/hivemq-community-edition.git
cd hivemq-community-edition
docker/build.sh
docker run hivemq/hivemq-ce
The Docker image hivemq/hivemq-ce
is created locally.
You can tag the image or use the TARGET_IMAGE
environment variable to manipulate the image name.
Unzip the created binary package
cd hivemq-ce-<version>
./bin/run.sh
For further development instructions see the contribution guidelines.
HiveMQ Community Edition offers an embedded mode and a programmatic API for integrating with Java/Java EE software.
Important
|
Until HiveMQ Community Edition 2020.3 is released embedded mode is only available from jitpack.io. |
If you use Gradle, include the following code in your build.gradle
file.
repositories {
...
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.hivemq.hivemq-community-edition:hivemq-community-edition-embedded:master-SNAPSHOT'
}
If you use Maven, include the following code in your pom.xml
file.
<project>
...
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.hivemq.hivemq-community-edition</groupId>
<artifactId>hivemq-community-edition-embedded</artifactId>
<version>master-SNAPSHOT</version>
</dependency>
</dependencies>
...
</project>
Note
|
You must set the compiler version to 11 or higher.
|
Entry into the embedded mode is done with the com.hivemq.embedded.EmbeddedHiveMQBuilder
.
public class Main {
public static void main(String[] args) {
final EmbeddedHiveMQBuilder embeddedHiveMQBuilder = EmbeddedHiveMQBuilder.builder()
.withConfigurationFolder(Path.of("/path/to/embedded-config-folder"))
.withDataFolder(Path.of("/path/to/embedded-data-folder"))
.withExtensionsFolder(Path.of("/path/to/embedded-extensions-folder"));
...
}
}
Once built, an EmbeddedHiveMQ can be started with start()
.
public class Main {
public static void main(String[] args) {
final EmbeddedHiveMQBuilder embeddedHiveMQBuilder = EmbeddedHiveMQBuilder.builder()
...;
try (final EmbeddedHiveMQ hiveMQ = embeddedHiveMQBuilder.build()) {
hiveMQ.start().join();
...
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
A running EmbeddedHiveMQ can be stopped with stop()
.
public class Main {
public static void main(String[] args) {
...
try (final EmbeddedHiveMQ hiveMQ = embeddedHiveMQBuilder.build()) {
...
hiveMQ.stop().join();
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
Note
|
An EmbeddedHiveMQ is a resource that is similar to a e.g. network connection and implements the java.lang.AutoCloseable interface.
Always use ARM (try with resources) or ensure a call to close() .
|
When you deploy an application that includes EmbeddedHiveMQ, it can be useful to exclude some dependencies. One way to exclude dependencies is with the maven shade plugin.
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<!--Exclude the undesired dependencies-->
<exclude>org.rocksdb:rocksdbjni</exclude>
<exclude>ch.qos.logback:logback-classic</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
To exclude the org.rocksdb:rocksdbjni
dependency, two internal configurations must be changed before you call start()
.
public class Main {
public static void main(String[] args) {
...
try (final EmbeddedHiveMQ hiveMQ = embeddedHiveMQBuilder.build()) {
InternalConfigurations.PAYLOAD_PERSISTENCE_TYPE.set(PersistenceType.FILE);
InternalConfigurations.RETAINED_MESSAGE_PERSISTENCE_TYPE.set(PersistenceType.FILE);
hiveMQ.start().join();
...
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
If you want to contribute to HiveMQ CE, see the contribution guidelines.
HiveMQ Community Edition is licensed under the APACHE LICENSE, VERSION 2.0
.
A copy of the license can be found here.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。