This Hello World extension sets a ClientLifecycleEventListener which logs the MQTT Version and identifier of every connecting and disconnecting client and registers a PublishInboundInterceptor to modify the payload of every Publish with the topic 'hello/world' to 'Hello World!'.
We strongly recommend to read the HiveMQ Extension Documentation to grasp the core concepts of HiveMQ extension development.
-
Clone this repository into a Java 11 Gradle project.
-
Execute the Gradle task
hivemqExtensionZip
to build the extension. -
Move the file:
build/hivemq-extension/hivemq-hello-world-extension-4.34.0.zip
to the directory:HIVEMQ_HOME/extensions
-
Unzip the file.
-
Start HiveMQ.
Connect with an MQTT client of your choice. You should see a log message with its identifier and MQTT version.
Execute the HelloWorldInterceptorIT
for automatic testing of the extension.
It uses the HiveMQ Testcontainer to automatically package, deploy and run the extension inside a HiveMQ docker container.
The test creates a HiveMQ MQTT Client to publish and receive a message with the topic 'hello/world'.
It checks whether the payload has been changed correctly to 'Hello World!'.
Awesome, you got your first HiveMQ 4 extension working.
Now read the HiveMQ Extension Documentation to see what extensions can do.
If you encounter any problems, we are happy to help. The best place to get in contact is our support.
If you want to contribute to HiveMQ Hello World Extension, see the contribution guidelines.
HiveMQ Hello World Extension is licensed under the APACHE LICENSE, VERSION 2.0
.
A copy of the license can be found here.