activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r383814 - /incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
Date Tue, 07 Mar 2006 07:39:40 GMT
Author: aco
Date: Mon Mar  6 23:39:39 2006
New Revision: 383814

URL: http://svn.apache.org/viewcvs?rev=383814&view=rev
Log:
Added a timeout to the client connection to prevent hanging.
Added some cleanup codes.

Modified:
    incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java

Modified: incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java?rev=383814&r1=383813&r2=383814&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
(original)
+++ incubator/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/http/HttpClientTransport.java
Mon Mar  6 23:39:39 2006
@@ -47,6 +47,8 @@
 public class HttpClientTransport extends HttpTransportSupport {
     private static final Log log = LogFactory.getLog(HttpClientTransport.class);
 
+    public static final int MAX_CLIENT_TIMEOUT = 20000;
+
     private HttpClient sendHttpClient;
     private HttpClient receiveHttpClient;
     private String clientID;
@@ -69,6 +71,7 @@
         httpMethod.setRequestBody(getTextWireFormat().toString(command));
         try {
             HttpClient client = getSendHttpClient();
+            client.setTimeout(MAX_CLIENT_TIMEOUT);
             int answer = client.executeMethod(httpMethod);
             if (answer != HttpStatus.SC_OK) {
                 throw new IOException("Failed to post command: " + command + " as response
was: " + answer);
@@ -77,6 +80,9 @@
         }
         catch (IOException e) {
             throw IOExceptionSupport.create("Could not post command: " + command + " due
to: " + e, e);
+        } finally {
+            httpMethod.getResponseBody();
+            httpMethod.releaseConnection();
         }
     }
 
@@ -116,6 +122,9 @@
             }
             catch (IOException e) {
                 log.warn("Failed to perform GET on: " + remoteUrl + " due to: " + e, e);
+            } finally {
+                httpMethod.getResponseBody();
+                httpMethod.releaseConnection();
             }
         }
     }



Mime
View raw message