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:32:14 UTC
[1/3] git commit: CAMEL-7014 setup the client timeout of
camel-restlet with thanks of Benjamin
Updated Branches:
refs/heads/master 00a4c52ae -> e60335d48
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/ad2e73bc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ad2e73bc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ad2e73bc
Branch: refs/heads/master
Commit: ad2e73bc9c4608d94802648e0dc3372984058796
Parents: 00a4c52
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 14:24:08 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/ad2e73bc/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/ad2e73bc/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;
}
[3/3] git commit: CAMEL-7014 Added the missing test file with some
changes
Posted by ni...@apache.org.
CAMEL-7014 Added the missing test file with some changes
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e60335d4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e60335d4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e60335d4
Branch: refs/heads/master
Commit: e60335d48ace847584870f3eacd15600a7edae85
Parents: 597e108
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Jan 6 14:37:50 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Jan 6 15:29:38 2014 +0800
----------------------------------------------------------------------
.../restlet/RestletProducerTimeoutTest.java | 54 ++++++++++++++++++++
1 file changed, 54 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e60335d4/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTimeoutTest.java b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTimeoutTest.java
new file mode 100644
index 0000000..68e3406
--- /dev/null
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerTimeoutTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.restlet;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class RestletProducerTimeoutTest extends RestletTestSupport {
+
+ @Test
+ public void testRestletProducerGet() throws Exception {
+ try {
+ String out = template.requestBodyAndHeader("restlet:http://localhost:" + portNum + "/users/123/basic?socketTimeout=100", null, "id", 123, String.class);
+ assertEquals("", null, out);
+ } catch (Exception ex) {
+ System.out.println("get the exception");
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").to("restlet:http://localhost:" + portNum + "/users/123/basic?socketTimeout=100").to("log:reply");
+
+ from("restlet:http://localhost:" + portNum + "/users/{id}/basic")
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ Thread.sleep(1000);
+ exchange.getOut().setBody("Here is the response");
+ }
+ });
+ }
+ };
+ }
+}
[2/3] git commit: CAMEL-7014 Added connectionTimeout option for
camel-restlet producer
Posted by ni...@apache.org.
CAMEL-7014 Added connectionTimeout option for camel-restlet producer
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/597e1080
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/597e1080
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/597e1080
Branch: refs/heads/master
Commit: 597e108019b5032b4de79462a0ba0c00672ca5ad
Parents: ad2e73b
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Jan 6 14:37:01 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Jan 6 14:37:01 2014 +0800
----------------------------------------------------------------------
.../camel/component/restlet/RestletEndpoint.java | 14 ++++++++++++--
.../camel/component/restlet/RestletProducer.java | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/597e1080/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 2caccd1..24ca7f9 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,7 +39,8 @@ 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 static final int DEFAULT_SOCKET_TIMEOUT = 30000;
+ private static final int DEFAULT_CONNECT_TIMEOUT = 30000;
private Method restletMethod = Method.GET;
@@ -50,7 +51,8 @@ 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 int socketTimeout = DEFAULT_SOCKET_TIMEOUT;
+ private int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
private String uriPattern;
// Optional and for consumer only. This allows a single route to service multiple URI patterns.
@@ -133,6 +135,14 @@ public class RestletEndpoint extends DefaultEndpoint implements HeaderFilterStra
public void setSocketTimeout(int socketTimeout) {
this.socketTimeout = socketTimeout;
}
+
+ public int getConnectTimeout() {
+ return connectTimeout;
+ }
+
+ public void setConnectTimeout(int connectTimeout) {
+ this.connectTimeout = connectTimeout;
+ }
public String getUriPattern() {
return uriPattern;
http://git-wip-us.apache.org/repos/asf/camel/blob/597e1080/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 2cad21f..3e9f8ff 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,7 +49,9 @@ public class RestletProducer extends DefaultAsyncProducer {
this.throwException = endpoint.isThrowExceptionOnFailure();
client = new Client(endpoint.getProtocol());
client.setContext(new Context());
+ client.setConnectTimeout(100);
client.getContext().getParameters().add("socketTimeout", String.valueOf(endpoint.getSocketTimeout()));
+ client.getContext().getParameters().add("socketConnectTimeoutMs", String.valueOf(endpoint.getSocketTimeout()));
}
@Override