adam-markovics commented on code in PR #1432:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1432#discussion_r1019193763


##########
extensions/mqtt/processors/AbstractMQTTProcessor.cpp:
##########
@@ -137,19 +148,45 @@ void AbstractMQTTProcessor::onSchedule(const 
std::shared_ptr<core::ProcessContex
 
 void AbstractMQTTProcessor::reconnect() {
   if (!client_) {
-    logger_->log_error("MQTT client is not existing while trying to 
reconnect");
-    return;
+    throw minifi::Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION, "MQTT 
client is not existing while trying to reconnect");
   }
   if (MQTTAsync_isConnected(client_)) {
-    logger_->log_info("Already connected to %s, no need to reconnect", uri_);
+    logger_->log_debug("Already connected to %s, no need to reconnect", uri_);
     return;
   }
-  MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
+
+  MQTTAsync_connectOptions conn_opts;
+  MQTTProperties connect_props = MQTTProperties_initializer;
+  MQTTProperties will_props = MQTTProperties_initializer;
+
+  if (mqtt_version_.value() == MqttVersions::V_5_0) {
+    conn_opts = MQTTAsync_connectOptions_initializer5;
+    conn_opts.onSuccess5 = connectionSuccess5;
+    conn_opts.onFailure5 = connectionFailure5;
+    conn_opts.connectProperties = &connect_props;
+  } else {
+    conn_opts = MQTTAsync_connectOptions_initializer;
+    conn_opts.onSuccess = connectionSuccess;
+    conn_opts.onFailure = connectionFailure;
+  }
+
+  if (mqtt_version_.value() == MqttVersions::V_3_1_0) {
+    conn_opts.MQTTVersion = MQTTVERSION_3_1;
+  } else if (mqtt_version_.value() == MqttVersions::V_3_1_1) {
+    conn_opts.MQTTVersion = MQTTVERSION_3_1_1;

Review Comment:
   `MQTTAsync_connectOptions_initializer5` does it on line 163.



-- 
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]

Reply via email to