HiveMQ

Sample git project using java mqtt client

Hi There,

Is there any sample git project available for publishing and subscribing to HiveMQ using Java?

Thanks & Regards,
-Venkat

Hi Venkat,

Did you already check the HiveMQ MQTT Client – Java client library? You can find it in GitHub at https://github.com/hivemq/hivemq-mqtt-client.

For publishing and subscribing you might find useful the following example: RequestResponse.java

I hope this helps,

Kind regards,
Dasha from HiveMQ team

Hi Daria,

Yes I went through it but it is not clear. Do you have any sample project where I can just download and start using and building on top of it.

Thanks & Regards,
-Venkat

Hey Venkat,

You can simply Git Clone the hivemq-mqtt-client and open the Gradle project from your IDE (for example, I am using IntelliJ IDEA).
Navigate to the the package with examples (src/main/java/com/hivemq/client/mqtt/examples) and you can run or debug then right from your IDE.
The RequestResponse.java seems a good example of how to publish and subscribe using the HiveMQ Public broker at broker.hivemq.com.

You might also find useful the Quick Start doc that contains all the steps necessary to integrate the HiveMQ MQTT Client library into a project, connect to a broker, then subscribe to a topic and publish messages to a topic.

Kind regards,
Dasha from HiveMQ team