You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/01/06 08:43:37 UTC

[2/3] git commit: CAMEL-7014 setup the client timeout of camel-restlet with thanks of Benjamin

CAMEL-7014 setup the client timeout of camel-restlet with thanks of Benjamin


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1e269c86
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1e269c86
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1e269c86

Branch: refs/heads/camel-2.12.x
Commit: 1e269c864b3d128971f67dd548858da961c7d9a2
Parents: fa1d427
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Jan 6 14:23:32 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Jan 6 15:43:12 2014 +0800

----------------------------------------------------------------------
 .../apache/camel/component/restlet/RestletEndpoint.java   | 10 ++++++++++
 .../apache/camel/component/restlet/RestletProducer.java   |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1e269c86/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java
index f27787b..2caccd1 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletEndpoint.java
@@ -39,6 +39,7 @@ public class RestletEndpoint extends DefaultEndpoint implements HeaderFilterStra
     private static final int DEFAULT_PORT = 80;
     private static final String DEFAULT_PROTOCOL = "http";
     private static final String DEFAULT_HOST = "localhost";
+    private static final int DEFAULT_SOCKETTIMEOUT = 30000;
 
     private Method restletMethod = Method.GET;
 
@@ -49,6 +50,7 @@ public class RestletEndpoint extends DefaultEndpoint implements HeaderFilterStra
     private String protocol = DEFAULT_PROTOCOL;
     private String host = DEFAULT_HOST;
     private int port = DEFAULT_PORT;
+    private int socketTimeout = DEFAULT_SOCKETTIMEOUT;
     private String uriPattern;
 
     // Optional and for consumer only. This allows a single route to service multiple URI patterns.
@@ -124,6 +126,14 @@ public class RestletEndpoint extends DefaultEndpoint implements HeaderFilterStra
         this.port = port;
     }
 
+    public int getSocketTimeout() {
+        return socketTimeout;
+    }
+
+    public void setSocketTimeout(int socketTimeout) {
+        this.socketTimeout = socketTimeout;
+    }
+
     public String getUriPattern() {
         return uriPattern;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/1e269c86/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
index b8d84c4..2cad21f 100644
--- a/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
+++ b/components/camel-restlet/src/main/java/org/apache/camel/component/restlet/RestletProducer.java
@@ -49,6 +49,7 @@ public class RestletProducer extends DefaultAsyncProducer {
         this.throwException = endpoint.isThrowExceptionOnFailure();
         client = new Client(endpoint.getProtocol());
         client.setContext(new Context());
+        client.getContext().getParameters().add("socketTimeout", String.valueOf(endpoint.getSocketTimeout()));
     }
 
     @Override
@@ -98,10 +99,10 @@ public class RestletProducer extends DefaultAsyncProducer {
                 } catch (Exception e) {
                     exchange.setException(e);
                 }
-                callback.done(false);
             }
         });
 
+        callback.done(false);
         return false;
     }