nandorsoma commented on code in PR #6225:
URL: https://github.com/apache/nifi/pull/6225#discussion_r957810380
##########
nifi-nar-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/PublishMQTT.java:
##########
@@ -201,35 +191,35 @@ private void initializeClient(ProcessContext context) {
// non-null but not connected, so we need to handle each case and only
create a new client when it is null
try {
if (mqttClient == null) {
- logger.debug("Creating client");
- mqttClient = createMqttClient(broker, clientID, persistence);
+ mqttClient = createMqttClient();
mqttClient.setCallback(this);
}
if (!mqttClient.isConnected()) {
- logger.debug("Connecting client");
- mqttClient.connect(connOpts);
+ mqttClient.connect();
}
- } catch (MqttException e) {
- logger.error("Connection to {} lost (or was never connected) and
connection failed. Yielding processor", new Object[]{broker}, e);
+ } catch (Exception e) {
+ logger.error("Connection to {} lost (or was never connected) and
connection failed. Yielding processor", clientProperties.getBroker(), e);
context.yield();
}
}
@Override
public void connectionLost(Throwable cause) {
- logger.error("Connection to {} lost due to: {}", new Object[]{broker,
cause.getMessage()}, cause);
+ logger.error("Connection to {} lost due to: {}", new
Object[]{clientProperties.getBroker(), cause.getMessage()}, cause);
}
@Override
- public void messageArrived(String topic, MqttMessage message) throws
Exception {
- logger.error("Message arrived to a PublishMQTT processor { topic:'" +
topic +"; payload:"+ Arrays.toString(message.getPayload())+"}");
+ public void messageArrived(ReceivedMqttMessage message) {
+ // Unlikely situation. Api uses the same callback for publisher and
consumer as well.
+ // That's why we have this log message here to indicate something
really messy thing happened.
+ logger.error("Message arrived to a PublishMQTT processor { topic:'" +
message.getTopic() + "; payload:" + Arrays.toString(message.getPayload()) +
"}");
}
@Override
- public void deliveryComplete(IMqttDeliveryToken token) {
+ public void deliveryComplete(String token) {
// Client.publish waits for message to be delivered so this token will
always have a null message and is useless in this application.
- logger.trace("Received 'delivery complete' message from broker for:" +
token.toString());
+ logger.trace("Received 'delivery complete' message from broker for:" +
token);
Review Comment:
Changed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]