@Override
public byte onSubscribe(final Topic topic) throws MQTTProtocolException {
final String destinationName = topic.name().toString();
final QoS requestedQoS = topic.qos();
final MQTTSubscription mqttSubscription = mqttSubscriptionByTopic.get(destinationName);
if (mqttSubscription != null) {
if (requestedQoS != mqttSubscription.getQoS()) {
// remove old subscription as the QoS has changed
onUnSubscribe(destinationName);
} else {
try {
onReSubscribe(mqttSubscription);
} catch (IOException e) {
throw new MQTTProtocolException("Failed to find subscription strategy", true, e);
}
return (byte) requestedQoS.ordinal();
}
}
try {
return onSubscribe(destinationName, requestedQoS);