You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/11/04 09:45:36 UTC

[camel] 01/02: CAMEL-11628: camel-mqtt - Fix in MQTTEndpoint for connection loop bug.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.19.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 857c66b7b7433bb768e321948da4e6f1af50bd11
Author: Brad Powell <ba...@sbcglobal.net>
AuthorDate: Fri Nov 3 11:36:56 2017 -0500

    CAMEL-11628: camel-mqtt - Fix in MQTTEndpoint for connection loop bug.
---
 .../main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
index 511c3c5..3dce618 100644
--- a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
+++ b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
@@ -231,6 +231,12 @@ public class MQTTEndpoint extends DefaultEndpoint implements AsyncEndpoint {
     }
 
     protected void createConnection() {
+        if (connection != null) {
+            // In connect(), in the connection.connect() callback, onFailure() doesn't seem to ever be called, so forcing the disconnect here.
+            // Without this, the fusesource MQTT client seems to be holding the old connection object, and connection contention can ensue.
+            connection.disconnect(null);
+        }
+    	
         connection = configuration.callbackConnection();
 
         connection.listener(new Listener() {
@@ -331,7 +337,7 @@ public class MQTTEndpoint extends DefaultEndpoint implements AsyncEndpoint {
 
             }
 
-            public void onFailure(Throwable value) {
+            public void onFailure(Throwable value) {  // this doesn't appear to ever be called
                 LOG.warn("Failed to connect to " + configuration.getHost() + " due " + value.getMessage());
                 promise.onFailure(value);
                 connection.disconnect(null);

-- 
To stop receiving notification emails like this one, please contact
"commits@camel.apache.org" <co...@camel.apache.org>.