On retained republish message adapt the QoS to the one specified during subscription (fix issue #411)

This commit is contained in:
andsel
2018-06-28 00:26:42 +02:00
parent 99226aadbd
commit 88e0ccf20e
6 changed files with 86 additions and 44 deletions
@@ -858,6 +858,14 @@ public class ProtocolProcessor {
newSubscription.getClientId(), newSubscription.getTopicFilter(), messages.size());
}
ClientSession targetSession = this.sessionsRepository.sessionForClient(newSubscription.getClientId());
// adapt the message QoS to subscriber's accepted accepted
for (IMessagesStore.StoredMessage msg : messages) {
int lowestQoS = Math.min(msg.getQos().value(), newSubscription.getRequestedQos().value());
MqttQoS qosToPublish = MqttQoS.valueOf(lowestQoS);
msg.setQos(qosToPublish);
}
this.internalRepublisher.publishRetained(targetSession, messages);
// notify the Observables