hivemq-community-edition
HiveMQ CE is a Java-based open source MQTT broker that fully supports MQTT 3.x and MQTT 5. It is the foundation of the HiveMQ Enterprise Connectivity and Messaging Platform
Top Related Projects
The most scalable MQTT broker for AI, IoT, IIoT, and connected vehicles
A distributed MQTT message broker based on Erlang/OTP. Built for high quality & Industrial use cases. The VerneMQ mission is active & the project maintained. Thank you for your support!
Eclipse Mosquitto - An open source MQTT broker
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Apache ActiveMQ Classic
Mirror of Apache Kafka
Quick Overview
HiveMQ Community Edition is an open-source MQTT broker that provides a scalable and efficient solution for IoT messaging. It offers high performance, reliability, and security features, making it suitable for both small-scale projects and enterprise-level deployments.
Pros
- High performance and scalability, capable of handling millions of concurrent MQTT connections
- Supports MQTT 3.1, 3.1.1, and 5.0 protocols
- Provides robust security features, including TLS encryption and authentication
- Offers easy integration with existing systems through various extension points
Cons
- Limited advanced features compared to the Enterprise Edition
- May require additional configuration for complex deployments
- Documentation could be more comprehensive for some advanced use cases
- Community support might be slower compared to commercial alternatives
Getting Started
To get started with HiveMQ Community Edition:
- Download the latest release from the GitHub repository.
- Extract the downloaded archive to a directory of your choice.
- Open a terminal and navigate to the extracted directory.
- Run the following command to start the broker:
bin/run.sh
- The broker will start and listen on port 1883 for MQTT connections.
To connect to the broker using an MQTT client library, use the following connection details:
- Host: localhost
- Port: 1883
- Protocol: MQTT
For secure connections, configure TLS and use port 8883 instead.
Competitor Comparisons
The most scalable MQTT broker for AI, IoT, IIoT, and connected vehicles
Pros of EMQX
- Supports more protocols (MQTT, MQTT-SN, CoAP, LwM2M, etc.)
- Built-in rule engine for message processing and data integration
- Scalable to millions of concurrent connections
Cons of EMQX
- Steeper learning curve due to more advanced features
- Less extensive documentation compared to HiveMQ
- Smaller community and ecosystem
Code Comparison
EMQX configuration (emqx.conf):
node.name = emqx@127.0.0.1
node.cookie = emqxsecretcookie
cluster.name = emqxcl
HiveMQ configuration (config.xml):
<hivemq>
<listeners>
<tcp-listener>
<port>1883</port>
<bind-address>0.0.0.0</bind-address>
</tcp-listener>
</listeners>
</hivemq>
Both EMQX and HiveMQ Community Edition are open-source MQTT brokers, but they differ in their approach and feature set. EMQX offers a wider range of supported protocols and a built-in rule engine, making it more versatile for complex IoT scenarios. However, this comes at the cost of a steeper learning curve and less extensive documentation. HiveMQ Community Edition, on the other hand, focuses on providing a robust MQTT broker with excellent documentation and a larger community, but with fewer advanced features out of the box.
A distributed MQTT message broker based on Erlang/OTP. Built for high quality & Industrial use cases. The VerneMQ mission is active & the project maintained. Thank you for your support!
Pros of VerneMQ
- Written in Erlang, offering excellent scalability and fault tolerance
- Supports clustering out-of-the-box for high availability
- Provides a plugin system for easy extensibility
Cons of VerneMQ
- Smaller community and ecosystem compared to HiveMQ
- Less comprehensive documentation and fewer enterprise features
- Steeper learning curve due to Erlang-based architecture
Code Comparison
VerneMQ configuration example:
{vmq_server, [
{listener, [
{tcp, 1883, [{max_connections, 10000}]}
]},
{max_client_id_size, 100},
{retry_interval, 20}
]}
HiveMQ Community Edition configuration example:
<hivemq>
<listeners>
<tcp-listener>
<port>1883</port>
<bind-address>0.0.0.0</bind-address>
</tcp-listener>
</listeners>
<mqtt>
<max-client-id-length>100</max-client-id-length>
</mqtt>
</hivemq>
Both VerneMQ and HiveMQ Community Edition are robust MQTT brokers, but they cater to different needs. VerneMQ excels in scalability and fault tolerance, making it suitable for large-scale deployments. HiveMQ Community Edition offers a more user-friendly experience with better documentation and a larger community, which can be beneficial for smaller projects or those new to MQTT brokers.
Eclipse Mosquitto - An open source MQTT broker
Pros of Mosquitto
- Lightweight and efficient, ideal for resource-constrained environments
- Extensive documentation and community support
- Simple setup and configuration process
Cons of Mosquitto
- Limited built-in clustering capabilities
- Fewer enterprise-grade features compared to HiveMQ
Code Comparison
Mosquitto configuration example:
listener 1883
allow_anonymous true
persistence true
persistence_location /var/lib/mosquitto/
HiveMQ configuration example:
<hivemq>
<listeners>
<tcp-listener>
<port>1883</port>
</tcp-listener>
</listeners>
<persistence>
<mode>file</mode>
</persistence>
</hivemq>
Both projects are open-source MQTT brokers, but they target different use cases. Mosquitto is lightweight and suitable for small to medium-scale deployments, while HiveMQ Community Edition offers more robust features for larger, enterprise-level implementations.
Mosquitto is written in C, making it highly efficient and suitable for embedded systems. HiveMQ is Java-based, providing better scalability and integration with enterprise Java ecosystems.
HiveMQ Community Edition offers built-in clustering capabilities, making it easier to set up distributed systems. Mosquitto requires additional configuration and third-party tools for clustering.
Both projects have active communities and regular updates, ensuring ongoing support and improvements.
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Pros of RabbitMQ Server
- Supports multiple messaging protocols (AMQP, MQTT, STOMP)
- Offers more advanced routing and message handling capabilities
- Has a larger and more established community
Cons of RabbitMQ Server
- Higher resource consumption and potentially lower performance at scale
- More complex configuration and setup process
- Less focused on MQTT-specific features and optimizations
Code Comparison
RabbitMQ Server (Erlang):
-module(rabbit_mqtt_reader).
-behaviour(gen_server2).
start_link(Conn, ProcessorState) ->
gen_server2:start_link(?MODULE, [Conn, ProcessorState], []).
HiveMQ Community Edition (Java):
public class MqttClientConnection implements ClientConnection {
@Override
public void onConnect(final @NotNull ConnectPacket connectPacket) {
// Handle MQTT connection
}
}
Both projects implement MQTT functionality, but RabbitMQ uses Erlang for its core implementation, while HiveMQ is written in Java. RabbitMQ's code reflects its multi-protocol nature, while HiveMQ's code is more focused on MQTT-specific operations.
Apache ActiveMQ Classic
Pros of ActiveMQ
- More mature and established project with a larger community
- Supports multiple protocols (AMQP, MQTT, STOMP) out of the box
- Offers additional features like message persistence and clustering
Cons of ActiveMQ
- Can be more complex to set up and configure
- Generally consumes more resources, especially for high-throughput scenarios
- May have slower performance compared to HiveMQ in certain use cases
Code Comparison
ActiveMQ (Java):
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue("myQueue");
MessageProducer producer = session.createProducer(destination);
HiveMQ (Java):
Mqtt5BlockingClient client = Mqtt5Client.builder()
.identifier(UUID.randomUUID().toString())
.serverHost("localhost")
.buildBlocking();
client.connect();
client.publishWith()
.topic("myTopic")
.qos(MqttQos.EXACTLY_ONCE)
.payload("Hello".getBytes())
.send();
Both repositories offer robust messaging solutions, but ActiveMQ provides a more comprehensive feature set at the cost of increased complexity. HiveMQ Community Edition focuses on MQTT specifically, offering a simpler setup and potentially better performance for MQTT-based applications.
Mirror of Apache Kafka
Pros of Kafka
- Higher throughput and scalability for large-scale data streaming
- Strong support for data retention and replay capabilities
- Extensive ecosystem with numerous connectors and integrations
Cons of Kafka
- More complex setup and configuration compared to HiveMQ
- Steeper learning curve for developers and operators
- Requires additional components like ZooKeeper (though this is changing)
Code Comparison
HiveMQ Community Edition (MQTT Publish):
MqttClient client = new MqttClient("tcp://broker.hivemq.com:1883", MqttClient.generateClientId());
client.connect();
MqttMessage message = new MqttMessage("Hello, MQTT!".getBytes());
client.publish("my/topic", message);
Kafka (Producer):
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
Producer<String, String> producer = new KafkaProducer<>(props);
producer.send(new ProducerRecord<>("my-topic", "Hello, Kafka!"));
Both HiveMQ Community Edition and Kafka are powerful messaging systems, but they serve different purposes. HiveMQ is focused on MQTT protocol and IoT use cases, offering simpler setup and management. Kafka, on the other hand, excels in high-throughput data streaming scenarios and provides robust data retention capabilities. The choice between the two depends on specific project requirements, scalability needs, and the preferred messaging protocol.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
++++
= HiveMQ Community Edition
image:https://maven-badges.herokuapp.com/maven-central/com.hivemq/hivemq-community-edition-embedded/badge.svg["Maven Central",link="https://maven-badges.herokuapp.com/maven-central/com.hivemq/hivemq-community-edition-embedded"] image:https://jitpack.io/v/hivemq/hivemq-community-edition.svg["JitPack",link="https://jitpack.io/#hivemq/hivemq-community-edition"] image:https://javadoc.io/badge2/com.hivemq/hivemq-community-edition-embedded/javadoc.svg["javadoc",link=https://javadoc.io/doc/com.hivemq/hivemq-community-edition-embedded] image:https://img.shields.io/github/actions/workflow/status/hivemq/hivemq-community-edition/check.yml?branch=master[GitHub Workflow Status (with branch),link=https://github.com/hivemq/hivemq-community-edition/actions/workflows/check.yml?query=branch%3Amaster]
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.
- Website: https://www.hivemq.com/
- Documentation: https://github.com/hivemq/hivemq-community-edition/wiki
- Community Forum: https://community.hivemq.com/
- Contribution guidelines: link:CONTRIBUTING.adoc[Contributing.adoc]
- License: The source files in this repository are made available under the link:LICENSE[Apache License Version 2.0].
== Features
- 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 https://github.com/hivemq/hivemq-mqtt-client[HiveMQ MQTT Client].
== Documentation
The documentation for the HiveMQ CE can be found https://github.com/hivemq/hivemq-community-edition/wiki[here].
MQTT Resources
- https://www.hivemq.com/mqtt-essentials/[MQTT Essentials]
- https://www.hivemq.com/mqtt-5/[MQTT 5 Essentials]
== HiveMQ Community Forum
The ideal place for questions or discussions about the HiveMQ Community Edition is our brand new https://community.hivemq.com/[HiveMQ Community Forum].
== How to Use
=== Quick Start
- Download the latest https://github.com/hivemq/hivemq-community-edition/releases/download/2025.1/hivemq-ce-2025.1.zip[HiveMQ CE binary package].
- Unzip the package.
- Run the run.sh (Linux/OSX) or run.bat (Windows) in the bin folder of the package.
[source,bash]
cd hivemq-ce-
bin/run.sh
[IMPORTANT]
At least Java version 11 is required to run HiveMQ CE.
If you are in doubt, you can check the installed Java version by entering java -version
on your command line.
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
Just in time builds for current branches on this repository and for specific commits are available https://hivemq.github.io/nightly-builds/[here].
=== Run with Docker
All releases as well as the current state of the master
branch are available in the https://hub.docker.com/r/hivemq/hivemq-ce[hivemq/hivemq-ce] repository on DockerHub.
To execute this image, simply run the following command:
[source,bash]
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:
[source,bash]
docker run --name hivemq-ce -e HIVEMQ_LOG_LEVEL=INFO -d -p 1883:1883 hivemq/hivemq-ce
=== Building from Source
==== Building the Binary Package
Check out the git repository and build the binary package.
[source,bash]
git clone https://github.com/hivemq/hivemq-community-edition.git
cd hivemq-community-edition
./gradlew hivemqZip
The package hivemq-ce-<version>.zip
is created in the sub-folder build/distributions/
.
==== Building the Docker Image
Check out the git repository and build the Docker image.
[source,bash]
git clone https://github.com/hivemq/hivemq-community-edition.git
cd hivemq-community-edition
./gradlew loadOciImage
The Docker image hivemq/hivemq-ce:snapshot
is created locally.
For further development instructions see the link:CONTRIBUTING.adoc[contribution guidelines].
=== Embedded Mode
HiveMQ Community Edition offers an embedded mode and a programmatic API for integrating with Java/Java EE software.
==== Gradle
If you use Gradle, include the following code in your build.gradle(.kts)
file.
[source,groovy]
dependencies { implementation("com.hivemq:hivemq-community-edition-embedded:2025.1") }
==== Maven
If you use Maven, include the following code in your pom.xml
file.
[source,xml]
NOTE: You must set the compiler version to 11
or higher.
==== Usage
Entry into the embedded mode is done with the com.hivemq.embedded.EmbeddedHiveMQBuilder
.
[source,java]
public class Main {
public static void main(String[] args) {
final EmbeddedHiveMQBuilder embeddedHiveMQBuilder = EmbeddedHiveMQ.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()
.
[source,java]
public class Main {
public static void main(String[] args) {
final EmbeddedHiveMQBuilder embeddedHiveMQBuilder = EmbeddedHiveMQ.builder();
...
try (final EmbeddedHiveMQ hiveMQ = embeddedHiveMQBuilder.build()) {
hiveMQ.start().join();
...
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
A running EmbeddedHiveMQ can be stopped with stop()
.
[source,java]
public class Main {
public static void main(String[] args) {
...
try (final EmbeddedHiveMQ hiveMQ = embeddedHiveMQBuilder.build()) {
...
hiveMQ.stop().join();
} catch (final Exception ex) {
ex.printStackTrace();
}
}
}
Similar to the embedded HiveMQ an embedded extension can be built with the com.hivemq.embedded.EmbeddedExtensionBuilder
.
Then add the embedded extension to the embedded HiveMQ builder.
[source,java]
public class Main {
public static void main(String[] args) {
final EmbeddedExtension embeddedExtension = EmbeddedExtension.builder()
.withId("embedded-ext-1")
.withName("Embedded Extension")
.withVersion("1.0.0")
.withPriority(0)
.withStartPriority(1000)
.withAuthor("Me")
.withExtensionMain(new MyEmbeddedExtensionMain())
.build();
final EmbeddedHiveMQBuilder builder = EmbeddedHiveMQ.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"))
.withEmbeddedExtension(embeddedExtension);
try (final EmbeddedHiveMQ hiveMQ = builder.build()) {
hiveMQ.start().join();
//do something with hivemq
} catch (final Exception ex) {
ex.printStackTrace();
}
}
private static class MyEmbeddedExtensionMain implements ExtensionMain {
@Override
public void extensionStart(final @NotNull ExtensionStartInput extensionStartInput, final @NotNull ExtensionStartOutput extensionStartOutput) {
// my extension start code
}
@Override
public void extensionStop(final @NotNull ExtensionStopInput extensionStopInput, final @NotNull ExtensionStopOutput extensionStopOutput) {
// my extension stop code
}
}
}
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()
.
==== Exclusions
When you deploy an application that includes EmbeddedHiveMQ, it can be useful to exclude some dependencies. One way to exclude dependencies is with the link:https://maven.apache.org/plugins/maven-shade-plugin/[maven shade plugin].
[source,xml]
===== RocksDB Exclusion
To exclude the org.rocksdb:rocksdbjni
dependency, two internal configurations must be changed before you call start()
.
[source,java]
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();
}
}
}
== Contributing
If you want to contribute to HiveMQ CE, see the link:CONTRIBUTING.adoc[contribution guidelines].
== License
HiveMQ Community Edition is licensed under the APACHE LICENSE, VERSION 2.0
.
A copy of the license can be found link:LICENSE[here].
Top Related Projects
The most scalable MQTT broker for AI, IoT, IIoT, and connected vehicles
A distributed MQTT message broker based on Erlang/OTP. Built for high quality & Industrial use cases. The VerneMQ mission is active & the project maintained. Thank you for your support!
Eclipse Mosquitto - An open source MQTT broker
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Apache ActiveMQ Classic
Mirror of Apache Kafka
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot