pvillard31 commented on code in PR #11804:
URL: https://github.com/apache/nifi/pull/11804#discussion_r4336309647


##########
nifi-extension-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/adapters/HiveMqV5ClientAdapter.java:
##########
@@ -157,7 +148,21 @@ public void 
setReceivedMessageHandler(ReceivedMqttMessageHandler handler) {
         });
     }
 
-    private static Mqtt5BlockingClient createClient(URI brokerUri, 
MqttClientProperties clientProperties, ComponentLog logger) throws TlsException 
{
+    private <T> T awaitWithTimeout(Future<T> future) {
+        try {
+            final T response = 
future.get(clientProperties.getConnectionTimeout(), TimeUnit.SECONDS);
+            logger.debug("Received response: {}", response);
+            return response;
+        } catch (Exception e) {
+            future.cancel(true);

Review Comment:
   Does `future.cancel(true)` on the HiveMQ connect future really close the 
pending connection, given that `stopClient()` skips `disconnect()` when not 
connected and `close()` does nothing for HiveMQ?



##########
nifi-extension-bundles/nifi-mqtt-bundle/nifi-mqtt-processors/src/main/java/org/apache/nifi/processors/mqtt/PublishMQTT.java:
##########
@@ -196,7 +196,10 @@ public void onTrigger(final ProcessContext context, final 
ProcessSession session
         if (!isConnected()) {
             synchronized (this) {
                 if (!isConnected()) {
-                    initializeClient(context);
+                    if (!initializeClient(context)) {

Review Comment:
   Could we extend an existing test in `TestPublishMQTT` to check that 
FlowFiles stay in the queue when the connection fails, now that the session is 
rolled back?



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