This Hello World customization uses two transformers.
-
One
mqtt-to-pubsub
transformer that forwards MQTT publish messages to Google Cloud Pub/Sub. This transformer reads the Google Cloud Pub/Sub topic from the custom settings of theconfig.xml
file and preserves the MQTT topic, retained flag, QoS level, and user properties as Pub/Sub message attributes. -
One
pubsub-to-mqtt
transformer that forwards Pub/Sub messages to HiveMQ. This transformer reads the QoS level from the custom settings of theconfig.xml
file, uses themqtt/topic
as the MQTT topic, and preserves every Pub/Sub attribute as MQTT user properties.
-
Clone this repository into a Java 11 Gradle project.
-
Run the
./gradlew jar
task from Gradle to build the customization. -
Move the
build/libs/hivemq-google-cloud-pubsub-hello-world-customization-4.35.0.jar
file to theHIVEMQ_HOME/extensions/hivemq-google-cloud-pubsub-extension/customizations
directory. -
Copy the
src/main/resources/google-cloud-pubsub-configuration.xml
file to theHIVEMQ_HOME/extensions/hivemq-google-cloud-pubsub-extension
folder. -
Adapt the configuration to your environment.
-
Set the
<google-cloud-project-id>
in the<pubsub-connection>
tag to match your Google Cloud Pub/Sub project ID. -
Set the
<file-path>
in the<service-account>
tag to the absolute or relative path of yourservice-account-key.json
file. -
Set the
<pubsub-subscription>
name in the<pubsub-to-mqtt-transformer>
tag to match the correct Google Cloud Pub/Sub subscription. -
Set the
<value>
of the destination<custom-setting>
in the<mqtt-to-pubsub-transformer>
to the correct Google Cloud Pub/Sub topic.
-
-
Delete the
HIVEMQ_HOME/extensions/hivemq-google-cloud-pubsub-extension/DISABLED
file (if there is one). -
Start HiveMQ.
-
Connect with an MQTT client of your choice.
-
Publish an MQTT message to the topic
topic/test
. -
Monitor the topic you configured in your Google Cloud Pub/Sub project for a received message. (Hint: Pub/Sub topics must have subscriptions or a message retention duration set for messages to be stored)
-
Connect with an MQTT client of your choice.
-
Subscribe to the topic
mqtt/topic
. -
Publish a Pub/Sub message to the Pub/Sub topic.
-
Verify that you receive an MQTT message with your client.
If you encounter any problems, we are happy to help. The best place to get in contact is our community forum.
HiveMQ Google Cloud Pub/Sub Extension Hello World Customization is licensed under the APACHE LICENSE, VERSION 2.0
.
A copy of the license can be found here.