Peeled common code
This commit is contained in:
@@ -56,19 +56,15 @@ class MessagesPublisher {
|
|||||||
sub.getClientId(), sub.getTopicFilter(), qos, targetIsActive);
|
sub.getClientId(), sub.getTopicFilter(), qos, targetIsActive);
|
||||||
ByteBuffer message = origMessage.duplicate();
|
ByteBuffer message = origMessage.duplicate();
|
||||||
if (targetIsActive) {
|
if (targetIsActive) {
|
||||||
//QoS 0
|
PublishMessage publishMsg = createPublishForQos(topic, qos, message);
|
||||||
if (qos == AbstractMessage.QOSType.MOST_ONE) {
|
if (qos != AbstractMessage.QOSType.MOST_ONE) {
|
||||||
PublishMessage publishMsg = createPublishForQos(topic, qos, message);
|
|
||||||
this.persistentSender.publishQos2(targetSession, publishMsg);
|
|
||||||
} else {
|
|
||||||
//QoS 1 or 2
|
//QoS 1 or 2
|
||||||
int messageId = targetSession.nextPacketId();
|
int messageId = targetSession.nextPacketId();
|
||||||
targetSession.inFlightAckWaiting(guid, messageId);
|
targetSession.inFlightAckWaiting(guid, messageId);
|
||||||
PublishMessage publishMsg = createPublishForQos(topic, qos, message);
|
|
||||||
//set the PacketIdentifier only for QoS > 0
|
//set the PacketIdentifier only for QoS > 0
|
||||||
publishMsg.setMessageID(messageId);
|
publishMsg.setMessageID(messageId);
|
||||||
this.persistentSender.publishQos2(targetSession, publishMsg);
|
|
||||||
}
|
}
|
||||||
|
this.persistentSender.sendPublish(targetSession, publishMsg);
|
||||||
} else {
|
} else {
|
||||||
if (!targetSession.isCleanSession()) {
|
if (!targetSession.isCleanSession()) {
|
||||||
//store the message in targetSession queue to deliver
|
//store the message in targetSession queue to deliver
|
||||||
|
|||||||
@@ -22,13 +22,12 @@ class PersistentQueueMessageSender {
|
|||||||
this.connectionDescriptors = connectionDescriptors;
|
this.connectionDescriptors = connectionDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void publishQos2(ClientSession clientsession, PublishMessage pubMessage) {
|
void sendPublish(ClientSession clientsession, PublishMessage pubMessage) {
|
||||||
String clientId = clientsession.clientID;
|
String clientId = clientsession.clientID;
|
||||||
LOG.debug("directSend invoked clientId <{}> on topic <{}> QoS {} retained {} messageID {}",
|
|
||||||
clientId, pubMessage.getTopicName(), pubMessage.getQos(), false, pubMessage.getMessageID());
|
|
||||||
|
|
||||||
LOG.info("send publish message to <{}> on topic <{}>", clientId, pubMessage.getTopicName());
|
LOG.info("send publish message to <{}> on topic <{}>", clientId, pubMessage.getTopicName());
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("directSend invoked clientId <{}> on topic <{}> QoS {} retained {} messageID {}",
|
||||||
|
clientId, pubMessage.getTopicName(), pubMessage.getQos(), false, pubMessage.getMessageID());
|
||||||
LOG.debug("content <{}>", DebugUtils.payload2Str(pubMessage.getPayload()));
|
LOG.debug("content <{}>", DebugUtils.payload2Str(pubMessage.getPayload()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user