broker/Qos1PublishHandler: code formatter used
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package io.moquette.spi.impl;
|
package io.moquette.spi.impl;
|
||||||
|
|
||||||
import io.moquette.server.ConnectionDescriptorStore;
|
import io.moquette.server.ConnectionDescriptorStore;
|
||||||
@@ -14,14 +15,13 @@ import io.netty.handler.codec.mqtt.MqttPubAckMessage;
|
|||||||
import io.netty.handler.codec.mqtt.MqttPublishMessage;
|
import io.netty.handler.codec.mqtt.MqttPublishMessage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static io.moquette.spi.impl.ProtocolProcessor.asStoredMessage;
|
import static io.moquette.spi.impl.ProtocolProcessor.asStoredMessage;
|
||||||
import static io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader.from;
|
import static io.netty.handler.codec.mqtt.MqttMessageIdVariableHeader.from;
|
||||||
import static io.netty.handler.codec.mqtt.MqttQoS.AT_MOST_ONCE;
|
import static io.netty.handler.codec.mqtt.MqttQoS.AT_MOST_ONCE;
|
||||||
|
|
||||||
class Qos1PublishHandler extends QosPublishHandler {
|
class Qos1PublishHandler extends QosPublishHandler {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(Qos1PublishHandler.class);
|
private static final Logger LOG = LoggerFactory.getLogger(Qos1PublishHandler.class);
|
||||||
|
|
||||||
private final SubscriptionsStore subscriptions;
|
private final SubscriptionsStore subscriptions;
|
||||||
@@ -32,8 +32,7 @@ class Qos1PublishHandler extends QosPublishHandler {
|
|||||||
|
|
||||||
public Qos1PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions,
|
public Qos1PublishHandler(IAuthorizator authorizator, SubscriptionsStore subscriptions,
|
||||||
IMessagesStore messagesStore, BrokerInterceptor interceptor,
|
IMessagesStore messagesStore, BrokerInterceptor interceptor,
|
||||||
ConnectionDescriptorStore connectionDescriptors,
|
ConnectionDescriptorStore connectionDescriptors, String brokerPort, MessagesPublisher messagesPublisher) {
|
||||||
String brokerPort, MessagesPublisher messagesPublisher) {
|
|
||||||
super(authorizator);
|
super(authorizator);
|
||||||
this.subscriptions = subscriptions;
|
this.subscriptions = subscriptions;
|
||||||
this.m_messagesStore = messagesStore;
|
this.m_messagesStore = messagesStore;
|
||||||
@@ -57,12 +56,20 @@ class Qos1PublishHandler extends QosPublishHandler {
|
|||||||
toStoreMsg.setClientID(clientID);
|
toStoreMsg.setClientID(clientID);
|
||||||
|
|
||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
LOG.trace("Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}, payload = {}, subscriptionTree = {}.",
|
LOG.trace(
|
||||||
clientID, topic, messageID, DebugUtils.payload2Str(toStoreMsg.getMessage()),
|
"Sending publish message to subscribers. "
|
||||||
|
+ "MqttClientId = {}, topic = {}, messageId = {}, payload = {}, subscriptionTree = {}.",
|
||||||
|
clientID,
|
||||||
|
topic,
|
||||||
|
messageID,
|
||||||
|
DebugUtils.payload2Str(toStoreMsg.getMessage()),
|
||||||
subscriptions.dumpTree());
|
subscriptions.dumpTree());
|
||||||
} else {
|
} else {
|
||||||
LOG.info("Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}.", clientID,
|
LOG.info(
|
||||||
topic, messageID);
|
"Sending publish message to subscribers. MqttClientId = {}, topic = {}, messageId = {}.",
|
||||||
|
clientID,
|
||||||
|
topic,
|
||||||
|
messageID);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Subscription> topicMatchingSubscriptions = subscriptions.matches(topic);
|
List<Subscription> topicMatchingSubscriptions = subscriptions.matches(topic);
|
||||||
@@ -94,11 +101,17 @@ class Qos1PublishHandler extends QosPublishHandler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (connectionDescriptors == null) {
|
if (connectionDescriptors == null) {
|
||||||
throw new RuntimeException("Internal bad error, found connectionDescriptors to null while it should be initialized, somewhere it's overwritten!!");
|
throw new RuntimeException(
|
||||||
|
"Internal bad error, found connectionDescriptors to null while it should be initialized, "
|
||||||
|
+ "somewhere it's overwritten!!");
|
||||||
}
|
}
|
||||||
LOG.debug("clientIDs are {}", connectionDescriptors);
|
LOG.debug("clientIDs are {}", connectionDescriptors);
|
||||||
if (!connectionDescriptors.isConnected(clientId)) {
|
if (!connectionDescriptors.isConnected(clientId)) {
|
||||||
throw new RuntimeException(String.format("Can't find a ConnectionDescriptor for client %s in cache %s", clientId, connectionDescriptors));
|
throw new RuntimeException(
|
||||||
|
String.format(
|
||||||
|
"Can't find a ConnectionDescriptor for client %s in cache %s",
|
||||||
|
clientId,
|
||||||
|
connectionDescriptors));
|
||||||
}
|
}
|
||||||
connectionDescriptors.sendMessage(pubAckMessage, messageID, clientId);
|
connectionDescriptors.sendMessage(pubAckMessage, messageID, clientId);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user