Skip to content

hivemq/hivemq-google-cloud-pubsub-hello-world-customization

Repository files navigation

HiveMQ Google Cloud Pub/Sub Extension Hello World Customization

Extension Type GitHub release (latest by date) GitHub

Purpose

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 the config.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 the config.xml file, uses the mqtt/topic as the MQTT topic, and preserves every Pub/Sub attribute as MQTT user properties.

Installation

  1. Clone this repository into a Java 11 Gradle project.

  2. Run the ./gradlew jar task from Gradle to build the customization.

  3. Move the build/libs/hivemq-google-cloud-pubsub-hello-world-customization-4.28.0.jar file to the HIVEMQ_HOME/extensions/hivemq-google-cloud-pubsub-extension/customizations directory.

  4. Copy the src/main/resources/google-cloud-pubsub-configuration.xml file to the HIVEMQ_HOME/extensions/hivemq-google-cloud-pubsub-extension folder.

  5. 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 your service-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.

  6. Delete the HIVEMQ_HOME/extensions/hivemq-google-cloud-pubsub-extension/DISABLED file (if there is one).

  7. Start HiveMQ.

First Steps

Manually Test Your MQTT-to-Pub/Sub Mapping

  • 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)

Manually Test Your Pub/Sub-to-MQTT Mapping

  • 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.

Need Help?

If you encounter any problems, we are happy to help. The best place to get in contact is our community forum.

License

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.