From d4a834743f6513dbc587d0c7f836bf703f4cfde6 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Wed, 23 Aug 2006 10:54:43 +0000 Subject: [PATCH] added the ability to configure the TCP keepAlive option git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@434006 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/transport/tcp/TcpTransport.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java b/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java index e4fc0664e9..04e49586d3 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java @@ -64,6 +64,7 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S protected boolean trace; protected boolean useLocalHost = true; protected int minmumWireFormatVersion; + private Boolean keepAlive; /** * Connect to a remote Node - e.g. a Broker @@ -206,11 +207,21 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S public void setConnectionTimeout(int connectionTimeout) { this.connectionTimeout = connectionTimeout; } - + + public Boolean getKeepAlive() { + return keepAlive; + } + + /** + * Enable/disable TCP KEEP_ALIVE mode + */ + public void setKeepAlive(Boolean keepAlive) { + this.keepAlive = keepAlive; + } + // Implementation methods // ------------------------------------------------------------------------- - protected String resolveHostName(String host) throws UnknownHostException { String localName = InetAddress.getLocalHost().getHostName(); if (localName != null && isUseLocalHost()) { @@ -237,6 +248,10 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S log.debug("Cannot set socket buffer size. Reason: " + se, se); } sock.setSoTimeout(soTimeout); + + if (keepAlive != null) { + sock.setKeepAlive(keepAlive.booleanValue()); + } } protected void doStart() throws Exception {