Search in sources :

Example 1 with MqttQos

use of com.hivemq.client.mqtt.datatypes.MqttQos in project open-smart-grid-platform by OSGP.

the class MqttClient method subscribe.

public void subscribe(final MessageHandler messageHandler) {
    if (this.isDisconnected()) {
        LOGGER.warn("Skipping subscribe, MQTT Client {} is disconnected", this.clientIdentifier);
        return;
    } else if (this.isWaitingForReconnect()) {
        LOGGER.warn("Skipping subscribe, MQTT Client {} is waiting for reconnect", this.clientIdentifier);
        return;
    }
    final MqttQos qos = MqttQos.valueOf(this.mqttClientDefaults.getDefaultQos());
    Arrays.stream(this.mqttClientDefaults.getDefaultTopics()).forEach(topic -> {
        this.unsubscribe(topic);
        this.subscribe(topic, qos, messageHandler);
    });
}
Also used : MqttQos(com.hivemq.client.mqtt.datatypes.MqttQos)

Example 2 with MqttQos

use of com.hivemq.client.mqtt.datatypes.MqttQos in project joynr by bmwcarit.

the class HivemqMqttClient method safeParseQos.

private MqttQos safeParseQos(int qosLevel) {
    MqttQos result = MqttQos.fromCode(qosLevel);
    if (result == null) {
        result = MqttQos.AT_LEAST_ONCE;
        logger.error("{}: Got invalid QoS level {} for publish, using default: {}", clientInformation, qosLevel, result.getCode());
    }
    return result;
}
Also used : MqttQos(com.hivemq.client.mqtt.datatypes.MqttQos)

Aggregations

MqttQos (com.hivemq.client.mqtt.datatypes.MqttQos)2