有MQTT 3.1.1和MQTT 5.0的所有功能
<!-- https://mvnrepository.com/artifact/com.hivemq/hivemq-mqtt-client -->
<dependency>
<groupId>com.hivemq</groupId>
<artifactId>hivemq-mqtt-client</artifactId>
<version>1.1.2</version>
</dependency>
// https://mvnrepository.com/artifact/com.hivemq/hivemq-mqtt-client
compile group: 'com.hivemq', name: 'hivemq-mqtt-client', version: '1.1.2'
//MQTT 5
Mqtt5Client client = MqttClient.builder()
.identifier(UUID.randomUUID().toString())
.serverHost("broker.hivemq.com")
.useMqttVersion5()
.build();
//MQTT 3
Mqtt3Client client = MqttClient.builder()...useMqttVersion3().build();
OR
Mqtt5Client client = Mqtt5Client.builder()...build();
Mqtt3Client client = Mqtt3Client.builder()...build();