nandorsoma commented on code in PR #6225:
URL: https://github.com/apache/nifi/pull/6225#discussion_r952882215


##########
nifi-nar-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/common/MqttConstants.java:
##########
@@ -67,14 +69,45 @@ public class MqttConstants {
      */
     public static final AllowableValue ALLOWABLE_VALUE_MQTT_VERSION_AUTO =
             new 
AllowableValue(String.valueOf(MqttConnectOptions.MQTT_VERSION_DEFAULT),
-                    "AUTO",
+                    "v3 AUTO",
                     "Start with v3.1.1 and fallback to v3.1.0 if not supported 
by a broker");
 
+    public static final AllowableValue ALLOWABLE_VALUE_MQTT_VERSION_500 =
+            new 
AllowableValue(String.valueOf(MqttVersion.MQTT_VERSION_5_0.getNumericValue()),
+                    "v5.0");
+
     public static final AllowableValue ALLOWABLE_VALUE_MQTT_VERSION_311 =
-            new 
AllowableValue(String.valueOf(MqttConnectOptions.MQTT_VERSION_3_1_1),
+            new 
AllowableValue(String.valueOf(MqttVersion.MQTT_VERSION_3_1_1.getNumericValue()),
                     "v3.1.1");
 
     public static final AllowableValue ALLOWABLE_VALUE_MQTT_VERSION_310 =
-            new 
AllowableValue(String.valueOf(MqttConnectOptions.MQTT_VERSION_3_1),
+            new 
AllowableValue(String.valueOf(MqttVersion.MQTT_VERSION_3_1.getNumericValue()),
                     "v3.1.0");
+
+    public enum MqttVersion {
+        MQTT_VERSION_3_1(3),
+        MQTT_VERSION_3_1_1(4),
+        MQTT_VERSION_5_0(5);
+
+        private final int numericValue;
+
+        MqttVersion(int numericValue) {
+            this.numericValue = numericValue;
+        }
+
+        public int getNumericValue() {
+            return numericValue;
+        }
+    }
+
+    public enum SupportedSchemes {

Review Comment:
   Changed.



##########
nifi-nar-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/common/MqttClientFactory.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.processors.mqtt.common;
+
+import com.hivemq.client.mqtt.mqtt5.Mqtt5Client;
+import com.hivemq.client.mqtt.mqtt5.Mqtt5ClientBuilder;
+import org.apache.nifi.processors.mqtt.adapters.HiveMqV5ClientAdapter;
+import org.apache.nifi.processors.mqtt.adapters.PahoMqttClientAdapter;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+
+import static 
org.apache.nifi.processors.mqtt.common.MqttConstants.SupportedSchemes.SSL;
+import static 
org.apache.nifi.processors.mqtt.common.MqttConstants.SupportedSchemes.WS;
+import static 
org.apache.nifi.processors.mqtt.common.MqttConstants.SupportedSchemes.WSS;
+
+public class MqttClientFactory {
+    public NifiMqttClient create(MqttClientProperties clientProperties, 
MqttConnectionProperties connectionProperties) {
+        switch (clientProperties.getMqttVersion()) {
+            case 0:
+            case 3:
+            case 4:
+                return createPahoMqttV3ClientAdapter(clientProperties);
+            case 5:
+                return createHiveMqV5ClientAdapter(clientProperties, 
connectionProperties);

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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to