Top Related Projects
High performance, distributed and low latency publish-subscribe platform.
Eclipse Mosquitto - An open source MQTT broker
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!
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
The most scalable and reliable MQTT broker for AI, IoT, IIoT and connected vehicles
Java MQTT lightweight broker
Quick Overview
HMQ is a high-performance, distributed MQTT broker written in Go. It supports MQTT 3.1.1 and 5.0 protocols, and is designed to handle a large number of concurrent connections efficiently.
Pros
- High performance and scalability, capable of handling millions of concurrent connections
- Supports both MQTT 3.1.1 and 5.0 protocols
- Cluster support for distributed deployments
- Flexible authentication and authorization mechanisms
Cons
- Limited documentation and examples for advanced configurations
- Fewer features compared to some more established MQTT brokers
- Relatively new project, which may lead to potential stability concerns
- Limited community support compared to more popular MQTT brokers
Code Examples
- Connecting to HMQ broker:
import (
mqtt "github.com/eclipse/paho.mqtt.golang"
)
opts := mqtt.NewClientOptions().AddBroker("tcp://localhost:1883")
client := mqtt.NewClient(opts)
if token := client.Connect(); token.Wait() && token.Error() != nil {
panic(token.Error())
}
- Publishing a message:
topic := "test/topic"
payload := "Hello, HMQ!"
token := client.Publish(topic, 0, false, payload)
token.Wait()
- Subscribing to a topic:
topic := "test/topic"
if token := client.Subscribe(topic, 0, nil); token.Wait() && token.Error() != nil {
fmt.Println(token.Error())
return
}
Getting Started
- Install HMQ:
go get github.com/fhmq/hmq
- Run HMQ:
hmq
-
Connect to HMQ using an MQTT client library of your choice, using the default port 1883 for non-TLS connections.
-
Publish and subscribe to topics as needed, following the MQTT protocol specifications.
Competitor Comparisons
High performance, distributed and low latency publish-subscribe platform.
Pros of Emitter
- More feature-rich, including support for presence, security, and clustering
- Better documentation and community support
- Actively maintained with regular updates
Cons of Emitter
- More complex setup and configuration
- Higher resource usage due to additional features
- Steeper learning curve for beginners
Code Comparison
Emitter (Go):
broker := broker.New()
broker.Listen(":8080")
HMQ (Go):
hmq := hmq.NewHmq()
hmq.Start()
Key Differences
- Emitter offers a more comprehensive MQTT solution with additional features like presence detection and security options
- HMQ focuses on simplicity and lightweight implementation
- Emitter has better documentation and community support, making it easier for developers to get started and troubleshoot issues
- HMQ may be more suitable for simple MQTT broker needs or resource-constrained environments
- Emitter provides better scalability options with built-in clustering support
Use Cases
- Choose Emitter for complex, feature-rich MQTT applications requiring advanced security and scalability
- Opt for HMQ when a lightweight, simple MQTT broker is needed, especially in resource-limited environments
Both projects are open-source and implemented in Go, making them suitable for cross-platform deployment and integration into existing Go-based systems.
Eclipse Mosquitto - An open source MQTT broker
Pros of Mosquitto
- More mature and widely adopted project with extensive documentation
- Supports a broader range of MQTT features and versions
- Cross-platform compatibility (Windows, Linux, macOS)
Cons of Mosquitto
- Written in C, which may be less accessible for some developers
- Can be more resource-intensive compared to lightweight alternatives
Code Comparison
Mosquitto (C):
int mosquitto_publish(struct mosquitto *mosq, int *mid, const char *topic, int payloadlen, const void *payload, int qos, bool retain)
HMQ (Go):
func (c *client) PublishMessage(msg *message.PublishMessage) error
Key Differences
- Mosquitto is written in C, while HMQ is written in Go
- Mosquitto offers more comprehensive MQTT support
- HMQ focuses on high performance and scalability
- Mosquitto has a larger community and ecosystem
- HMQ provides built-in clustering capabilities
Use Cases
Mosquitto:
- Enterprise-grade MQTT deployments
- IoT projects requiring full MQTT specification support
- Cross-platform applications
HMQ:
- High-performance MQTT broker requirements
- Go-based projects seeking easy integration
- Scenarios where clustering is a priority
Both projects offer MQTT broker functionality, but Mosquitto is more established and feature-rich, while HMQ emphasizes performance and Go ecosystem compatibility.
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
- More mature and feature-rich MQTT broker with extensive documentation
- Supports clustering for high availability and scalability
- Offers plugin system for extensibility and customization
Cons of VerneMQ
- Written in Erlang, which may have a steeper learning curve for some developers
- Larger codebase and potentially higher resource usage
- More complex setup and configuration compared to HMQ
Code Comparison
VerneMQ (Erlang):
handle_publish(Topic, Payload, _Opts, State) ->
io:format("Received message on topic ~p: ~p~n", [Topic, Payload]),
{ok, State}.
HMQ (Go):
func (c *client) ProcessPublish(msg *message.PublishMessage) {
fmt.Printf("Received message on topic %s: %s\n", msg.Topic(), msg.Payload())
}
Both repositories implement MQTT brokers, but VerneMQ offers a more comprehensive solution with advanced features and scalability options. HMQ, being written in Go, may be easier for some developers to understand and modify. VerneMQ is better suited for large-scale deployments, while HMQ could be a good choice for simpler use cases or when Go expertise is available.
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
Pros of HiveMQ Community Edition
- More comprehensive documentation and community support
- Offers clustering capabilities for scalability
- Provides a web-based dashboard for monitoring and management
Cons of HiveMQ Community Edition
- Larger resource footprint due to its Java-based implementation
- More complex setup and configuration process
- Limited customization options compared to HMQ
Code Comparison
HMQ (Go):
func (c *client) ProcessPublish(packet *packets.PublishPacket) {
topic := packet.TopicName
payload := packet.Payload
// Process publish message
}
HiveMQ Community Edition (Java):
@Override
public void onPublish(PUBLISH publish) {
String topic = publish.getTopic();
byte[] payload = publish.getPayload();
// Process publish message
}
Both implementations handle MQTT publish messages, but HMQ uses Go's lightweight approach, while HiveMQ Community Edition leverages Java's object-oriented structure. HMQ's code is more concise, potentially offering better performance for high-throughput scenarios. However, HiveMQ Community Edition's approach may provide better maintainability and extensibility for complex use cases.
The most scalable and reliable MQTT broker for AI, IoT, IIoT and connected vehicles
Pros of EMQX
- More feature-rich and scalable, supporting millions of concurrent MQTT connections
- Extensive documentation and enterprise support options
- Active development with frequent updates and a larger community
Cons of EMQX
- More complex setup and configuration compared to HMQ
- Higher resource requirements due to its comprehensive feature set
- Steeper learning curve for beginners
Code Comparison
HMQ (Go):
func (c *client) ProcessPublish(msg *message.PublishMessage) {
topic := string(msg.Topic())
r := c.srv.sl.Match(topic)
// ... (implementation details)
}
EMQX (Erlang):
handle_publish(Packet, State) ->
Topic = emqx_message:topic(Packet),
Subscribers = emqx_router:match_routes(Topic),
% ... (implementation details)
Both implementations handle MQTT publish messages, but EMQX's codebase is more extensive and modular, reflecting its broader feature set and scalability focus. HMQ's code is more straightforward, aligning with its lightweight design philosophy.
Java MQTT lightweight broker
Pros of Moquette
- Written in Java, offering better integration with Java-based systems
- More extensive documentation and community support
- Supports WebSocket connections out of the box
Cons of Moquette
- Generally slower performance compared to HMQ
- Higher memory usage, especially for large-scale deployments
- Less frequent updates and maintenance
Code Comparison
Moquette (Java):
Server server = new Server();
Properties config = new Properties();
config.setProperty(BrokerConstants.PORT_PROPERTY_NAME, "1883");
server.startServer(config);
HMQ (Go):
hmq := broker.NewHmq()
hmq.Start()
Both projects aim to provide MQTT broker functionality, but HMQ focuses on high performance and low resource usage, while Moquette offers better Java ecosystem integration and more extensive features. HMQ's codebase is more concise and efficient, reflecting its Go implementation, while Moquette's Java code is more verbose but potentially more familiar to Java developers.
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
Free and High Performance MQTT Broker
About
Golang MQTT Broker, Version 3.1.1, and Compatible for eclipse paho client and mosquitto-client
RUNNING
$ go get github.com/fhmq/hmq
$ cd $GOPATH/github.com/fhmq/hmq
$ go run main.go
Usage of hmq:
Usage: hmq [options]
Broker Options:
-w, --worker <number> Worker num to process message, perfer (client num)/10. (default 1024)
-p, --port <port> Use port for clients (default: 1883)
--host <host> Network host to listen on. (default "0.0.0.0")
-ws, --wsport <port> Use port for websocket monitoring
-wsp,--wspath <path> Use path for websocket monitoring
-c, --config <file> Configuration file
Logging Options:
-d, --debug <bool> Enable debugging output (default false)
-D Debug enabled
Cluster Options:
-r, --router <rurl> Router who maintenance cluster info
-cp, --clusterport <cluster-port> Cluster listen port for others
Common Options:
-h, --help Show this message
hmq.config
{
"workerNum": 4096,
"port": "1883",
"host": "0.0.0.0",
"cluster": {
"host": "0.0.0.0",
"port": "1993"
},
"router": "127.0.0.1:9888",
"wsPort": "1888",
"wsPath": "/ws",
"wsTLS": true,
"tlsPort": "8883",
"tlsHost": "0.0.0.0",
"tlsInfo": {
"verify": true,
"caFile": "tls/ca/cacert.pem",
"certFile": "tls/server/cert.pem",
"keyFile": "tls/server/key.pem"
},
"plugins": {
"auth": "authhttp",
"bridge": "kafka"
}
}
Features and Future
-
Supports QOS 0 and 1
-
Cluster Support
-
Containerization
-
Supports retained messages
-
Supports will messages
-
Websocket Support
-
TLS/SSL Support
-
Auth Support
- Auth Connect
- Auth ACL
- Cache Support
-
Kafka Bridge Support
- Action Deliver
- Regexp Deliver
-
HTTP API
- Disconnect Connect (future more)
Share SUBSCRIBE
| Prefix | Examples | Publish |
| ------------------- |-------------------------------------------|--------------------------- --|
| $share/<group>/topic | mosquitto_sub -t â$share/<group>/topicâ | mosquitto_pub -t âtopicâ |
Cluster
1, start router for hmq (https://github.com/fhmq/router.git)
$ go get github.com/fhmq/router
$ cd $GOPATH/github.com/fhmq/router
$ go run main.go
2, config router in hmq.config ("router": "127.0.0.1:9888")
Other Version Of Cluster Based On gRPC: click here
Online/Offline Notification
topic:
$SYS/broker/connection/clients/<clientID>
payload:
{"clientID":"client001","online":true/false,"timestamp":"2018-10-25T09:32:32Z"}
Performance
-
High throughput
-
High concurrency
-
Low memory and CPU
License
- Apache License Version 2.0
Reference
- Surgermq.(https://github.com/zentures/surgemq)
Benchmark Tool
Top Related Projects
High performance, distributed and low latency publish-subscribe platform.
Eclipse Mosquitto - An open source MQTT broker
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!
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
The most scalable and reliable MQTT broker for AI, IoT, IIoT and connected vehicles
Java MQTT lightweight broker
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