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 2018/07/20 11:31:49 UTC

[camel] 01/02: CAMEL-12669 - Camel-Nats: add new client options available with client 2.x - maxPingsOut

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

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9441b89d8963996447700e1553b956abc74421fb
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Jul 20 13:27:09 2018 +0200

    CAMEL-12669 - Camel-Nats: add new client options available with client 2.x - maxPingsOut
---
 components/camel-nats/src/main/docs/nats-component.adoc  |  3 ++-
 .../apache/camel/component/nats/NatsConfiguration.java   | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/components/camel-nats/src/main/docs/nats-component.adoc b/components/camel-nats/src/main/docs/nats-component.adoc
index 8f55119..337ee7a 100644
--- a/components/camel-nats/src/main/docs/nats-component.adoc
+++ b/components/camel-nats/src/main/docs/nats-component.adoc
@@ -66,7 +66,7 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (22 parameters):
+==== Query Parameters (23 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -75,6 +75,7 @@ with the following path and query parameters:
 | *connectionTimeout* (common) | Timeout for connection attempts. (in milliseconds) | 2000 | int
 | *flushConnection* (common) | Define if we want to flush connection or not | false | boolean
 | *flushTimeout* (common) | Set the flush timeout (in milliseconds) | 1000 | int
+| *maxPingsOut* (common) | maximum number of pings have not received a response allowed by the client | 2 | int
 | *maxReconnectAttempts* (common) | Max reconnection attempts | 60 | int
 | *noEcho* (common) | Turn off echo. If supported by the gnatsd version you are connecting to this flag will prevent the server from echoing messages back to the connection if it has subscriptions on the subject being published to. | false | boolean
 | *noRandomizeServers* (common) | Whether or not randomizing the order of servers for the connection attempts | false | boolean
diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java
index 2443269..e5b6fab 100644
--- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java
+++ b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConfiguration.java
@@ -51,6 +51,8 @@ public class NatsConfiguration {
     private int pingInterval = 120000;
     @UriParam(label = "common", defaultValue = "2000")
     private int connectionTimeout = 2000;
+    @UriParam(label = "common", defaultValue = "2")
+    private int maxPingsOut = Options.DEFAULT_MAX_PINGS_OUT;
     @UriParam(label = "producer")
     private String replySubject;
     @UriParam
@@ -149,8 +151,21 @@ public class NatsConfiguration {
     public void setMaxReconnectAttempts(int maxReconnectAttempts) {
         this.maxReconnectAttempts = maxReconnectAttempts;
     }
+    
 
     /**
+     * maximum number of pings have not received a response allowed by the 
+     * client
+     */
+    public int getMaxPingsOut() {
+		return maxPingsOut;
+	}
+
+	public void setMaxPingsOut(int maxPingsOut) {
+		this.maxPingsOut = maxPingsOut;
+	}
+
+	/**
      * Ping interval to be aware if connection is still alive (in milliseconds)
      */
     public int getPingInterval() {
@@ -306,6 +321,7 @@ public class NatsConfiguration {
         }
         builder.pingInterval(Duration.ofMillis(getPingInterval()));
         builder.connectionTimeout(Duration.ofMillis(getConnectionTimeout()));
+        builder.maxPingsOut(getMaxPingsOut());
         if (getNoRandomizeServers()) {
             builder.noRandomize();
         }