You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/08/04 13:18:19 UTC
camel git commit: CAMEL-11631, Camel-Paho Missiong reconnect logic
Repository: camel
Updated Branches:
refs/heads/master d03814435 -> f3472922a
CAMEL-11631, Camel-Paho Missiong reconnect logic
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f3472922
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f3472922
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f3472922
Branch: refs/heads/master
Commit: f3472922a694473115377e676bd84e39d5e9ba0f
Parents: d038144
Author: Fabrizio Spataro <fa...@bizmate.it>
Authored: Fri Aug 4 14:30:10 2017 +0200
Committer: Fabrizio Spataro <fa...@bizmate.it>
Committed: Fri Aug 4 14:30:10 2017 +0200
----------------------------------------------------------------------
.../src/main/docs/paho-component.adoc | 3 ++-
.../camel/component/paho/PahoEndpoint.java | 20 ++++++++++++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f3472922/components/camel-paho/src/main/docs/paho-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-paho/src/main/docs/paho-component.adoc b/components/camel-paho/src/main/docs/paho-component.adoc
index 8c3f578..2c20f19 100644
--- a/components/camel-paho/src/main/docs/paho-component.adoc
+++ b/components/camel-paho/src/main/docs/paho-component.adoc
@@ -149,11 +149,12 @@ with the following path and query parameters:
| **topic** | *Required* Name of the topic | | String
|=======================================================================
-#### Query Parameters (11 parameters):
+#### Query Parameters (12 parameters):
[width="100%",cols="2,5,^1,2",options="header"]
|=======================================================================
| Name | Description | Default | Type
+| **autoReconnect** (common) | Client will automatically attempt to reconnect to the server if the connection is lost | true | boolean
| **brokerUrl** (common) | The URL of the MQTT broker. | tcp://localhost:1883 | String
| **clientId** (common) | MQTT client identifier. | | String
| **connectOptions** (common) | Client connection options | | MqttConnectOptions
http://git-wip-us.apache.org/repos/asf/camel/blob/f3472922/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
index ed06f59..16af7d1 100644
--- a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
+++ b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
@@ -61,6 +61,8 @@ public class PahoEndpoint extends DefaultEndpoint {
private PahoPersistence persistence = PahoPersistence.MEMORY;
@UriParam(description = "Base directory used by file persistence. Will by default use current directory.")
private String filePersistenceDirectory;
+ @UriParam(defaultValue = "true")
+ private boolean autoReconnect = true;
// Collaboration members
@UriParam
@@ -111,7 +113,6 @@ public class PahoEndpoint extends DefaultEndpoint {
}
// Resolvers
-
protected MqttClientPersistence resolvePersistence() {
if (persistence == PahoPersistence.MEMORY) {
return new MemoryPersistence();
@@ -136,7 +137,10 @@ public class PahoEndpoint extends DefaultEndpoint {
LOG.warn("Found {} instances of the MqttConnectOptions in the registry. None of these will be used by the endpoint. "
+ "Please use 'connectOptions' endpoint option to select one.", connectOptions.size());
}
- return new MqttConnectOptions();
+
+ MqttConnectOptions options = new MqttConnectOptions();
+ options.setAutomaticReconnect(autoReconnect);
+ return options;
}
public Exchange createExchange(MqttMessage mqttMessage, String topic) {
@@ -255,4 +259,16 @@ public class PahoEndpoint extends DefaultEndpoint {
this.connectOptions = connOpts;
}
+ public synchronized boolean isAutoReconnect() {
+ return autoReconnect;
+ }
+
+ /**
+ * Client will automatically attempt to reconnect to the server if the connection is lost
+ * @param autoReconnect
+ */
+ public synchronized void setAutoReconnect(boolean autoReconnect) {
+ this.autoReconnect = autoReconnect;
+ }
+
}