From 6eb635f437627e541e08008fe5cdd51ea90a3aa1 Mon Sep 17 00:00:00 2001 From: Andreas Mager Date: Wed, 1 Feb 2017 15:52:35 +0100 Subject: [PATCH] broker/PersistentQueueMessageSender: code formatter used --- .../impl/PersistentQueueMessageSender.java | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/broker/src/main/java/io/moquette/spi/impl/PersistentQueueMessageSender.java b/broker/src/main/java/io/moquette/spi/impl/PersistentQueueMessageSender.java index bb27e27d..3dbef971 100644 --- a/broker/src/main/java/io/moquette/spi/impl/PersistentQueueMessageSender.java +++ b/broker/src/main/java/io/moquette/spi/impl/PersistentQueueMessageSender.java @@ -1,3 +1,4 @@ + package io.moquette.spi.impl; import io.moquette.server.ConnectionDescriptorStore; @@ -6,7 +7,6 @@ import io.netty.handler.codec.mqtt.MqttPublishMessage; import io.netty.handler.codec.mqtt.MqttQoS; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import static io.moquette.spi.impl.ProtocolProcessor.asStoredMessage; import static io.netty.handler.codec.mqtt.MqttQoS.AT_MOST_ONCE; @@ -21,27 +21,41 @@ class PersistentQueueMessageSender { void sendPublish(ClientSession clientsession, MqttPublishMessage pubMessage) { String clientId = clientsession.clientID; - final int messageId = pubMessage.variableHeader().messageId(); - final String topicName = pubMessage.variableHeader().topicName(); + final int messageId = pubMessage.variableHeader().messageId(); + final String topicName = pubMessage.variableHeader().topicName(); if (LOG.isDebugEnabled()) { - LOG.debug("Sending PUBLISH message. MessageId={}, CId={}, topic={}, qos={}, payload={}", messageId, - clientId, topicName, DebugUtils.payload2Str(pubMessage.payload())); + LOG.debug( + "Sending PUBLISH message. MessageId={}, CId={}, topic={}, qos={}, payload={}", + messageId, + clientId, + topicName, + DebugUtils.payload2Str(pubMessage.payload())); } else { - LOG.info("Sending PUBLISH message. MessageId={}, CId={}, topic={}", messageId, clientId, topicName); + LOG.info("Sending PUBLISH message. MessageId={}, CId={}, topic={}", messageId, clientId, topicName); } - boolean messageDelivered = connectionDescriptorStore.sendMessage(pubMessage, messageId, clientId); + boolean messageDelivered = connectionDescriptorStore.sendMessage(pubMessage, messageId, clientId); - MqttQoS qos = pubMessage.fixedHeader().qosLevel(); - if (!messageDelivered && qos != AT_MOST_ONCE && !clientsession.isCleanSession()) { - LOG.warn( - "The PUBLISH message could not be delivered. It will be stored. MessageId = {}, CId={}, topic = {}, qos = {}, cleanSession = {}.", - messageId, clientId, topicName, qos, false); - clientsession.enqueue(asStoredMessage(pubMessage)); - } else { - LOG.warn( - "The PUBLISH message could not be delivered. It will be discarded. MessageId = {}, CId={}, topic = {}, qos = {}, cleanSession = {}.", - messageId, clientId, topicName, qos, true); - } + MqttQoS qos = pubMessage.fixedHeader().qosLevel(); + if (!messageDelivered && qos != AT_MOST_ONCE && !clientsession.isCleanSession()) { + LOG.warn( + "The PUBLISH message could not be delivered. It will be stored. " + + "MessageId = {}, CId={}, topic = {}, qos = {}, cleanSession = {}.", + messageId, + clientId, + topicName, + qos, + false); + clientsession.enqueue(asStoredMessage(pubMessage)); + } else { + LOG.warn( + "The PUBLISH message could not be delivered. It will be discarded. " + + "MessageId = {}, CId={}, topic = {}, qos = {}, cleanSession = {}.", + messageId, + clientId, + topicName, + qos, + true); + } } }