Shared Subscriptions, Certificate based authentication

Can anyone point me to example code that implements an MQTT 5 backend client connecting with a certificate and implements shared subscriptions? My use case involves potentially millions of IoT devices publishing to a single topic. I need a backend client that can auto-scale and handle that sort of load. One of the requirements is that all clients must use certificate-based authentication. My intention was to implement the backend client in java (maybe a quarkus microservice). This is my first MQTT project. I understand the architecture needed and I am in the initial phases of figuring out the implementation and deciding what vendor(s) to use.

Hi @johnh ,

It is great that you are interested in MQTT and HiveMQ. Welcome to our community!

HiveMQ MQTT Client Library actually is an MQTT 5.0 compatible and feature-rich high-performance Java client library. It is open source so you can clone or fork it from the GitHub repository and explore how all features are implemented.
Documentation of HiveMQ MQTT Client Library you can learn here: Home - HiveMQ MQTT Client as well as JavaDoc for the APIs.

Before your own project works, it is useful to test connection to the broker (including SSL “with certficates”) with already working application. For this we recommend HiveMQ MQTT CLI. This application is a command line interface built on HiveMQ MQTT Java Client Library.
HiveMQ CLI is an Open Source project backed by HiveMQ. Which means you can explore it in the GitHub repository, clone or fork it for yourself and “play” or improve it.
HiveMQ MQTT CLI also has great documentation that you surely find helpful. For example, secure connection options “with certificates” documented here. And if you are curious about implementation you can always take a look at the source code (see in the GitHub repo).

You indicated that you are interested in Shared Subscriptions. These are a feature of the broker rather than client. For the client it is just a “special” name of the topic that the client subscribes. For example HiveMQ Broker supports Shared subscriptions. You can find this and other documentation here.
Hint: you can quickly test this and other MQTT features with a public broker hosted by HiveMQ: MQTT Dashboard
If you ever need help on HiveMQ broker, please feel free to post your question in respective category of our forum.

Have great fun with MQTT!
Dasha from HiveMQ Team

Hi Dasha,

Prior to posting this question I had already brought up a hiveMQ broker and created simple clients that were able to connect to it. I hope I don’t offend here but I have been through a lot of your documentation and watched a lot of your content on youtube. This content is very heavy on bla bla bla and as far as I can find very light on actual working examples. A library of simple real-world examples linked from your main page and elseware would be far more helpful to me than all the information you have put out that I have covered combined. I have looked at the javadocs for hiveMQ client and short of the standard stuff javadocs spits out there is little to no additional documentation or examples on the individual classes. Trying to go to gitHub and read code doesn’t really help a ton. Also, while I am certainly no expert by any means I don’t think shared subscriptions are just a broker thing. Yeah, the broker needs to be configured to handle the shared subscriptions but it’s a pool of actual clients that share that subscription. Setting up that pool is what I would love to see examples of. I need to listen to millions of devices at once on the same topic and write the incoming information to a database. It’s not just the broker that needs to scale it’s this client pool that needs to bring up multiple instances that share a subscription to those devices and scale. I know most of the engineers I work with feel the same about example code. Hopefully, my input could help you better support your community.

Thank you,