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 10:11:39 UTC

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

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 62932ca9c2c4a60aa103ecee9181d8558155851f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Jul 20 11:59:30 2018 +0200

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

diff --git a/components/camel-nats/src/main/docs/nats-component.adoc b/components/camel-nats/src/main/docs/nats-component.adoc
index e5fc2f2..b928cf5 100644
--- a/components/camel-nats/src/main/docs/nats-component.adoc
+++ b/components/camel-nats/src/main/docs/nats-component.adoc
@@ -66,12 +66,13 @@ with the following path and query parameters:
 |===
 
 
-==== Query Parameters (21 parameters):
+==== Query Parameters (22 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
+| *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
 | *maxReconnectAttempts* (common) | Max reconnection attempts | 3 | int
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 55b4262..bfa6873 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
@@ -49,6 +49,8 @@ public class NatsConfiguration {
     private int maxReconnectAttempts = 3;
     @UriParam(defaultValue = "4000")
     private int pingInterval = 4000;
+    @UriParam(label = "common", defaultValue = "2000")
+    private int connectionTimeout = 2000;
     @UriParam(label = "producer")
     private String replySubject;
     @UriParam
@@ -158,8 +160,19 @@ public class NatsConfiguration {
     public void setPingInterval(int pingInterval) {
         this.pingInterval = pingInterval;
     }
-
+    
     /**
+     * Timeout for connection attempts. (in milliseconds)
+     */
+    public int getConnectionTimeout() {
+		return connectionTimeout;
+	}
+
+	public void setConnectionTimeout(int connectionTimeout) {
+		this.connectionTimeout = connectionTimeout;
+	}
+
+	/**
      * the subject to which subscribers should send response
      */
     public String getReplySubject() {
@@ -292,6 +305,7 @@ public class NatsConfiguration {
             builder.reconnectWait(Duration.ofMillis(getReconnectTimeWait()));
         }
         builder.pingInterval(Duration.ofMillis(getPingInterval()));
+        builder.connectionTimeout(Duration.ofMillis(getConnectionTimeout()));
         if (getNoRandomizeServers()) {
             builder.noRandomize();
         }