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

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

commit 6dd206b6a08f71620dcbdf87e2d0c6b10881490c
Author: Brad Powell <bapow...@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" <commits@camel.apache.org>.

Reply via email to