activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1101866 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/tcp/ test/java/org/apache/activemq/transport/tcp/ test/resources/org/apache/activemq/transport/stomp/
Date Wed, 11 May 2011 13:17:53 GMT
Author: gtully
Date: Wed May 11 13:17:53 2011
New Revision: 1101866

URL: http://svn.apache.org/viewvc?rev=1101866&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3315 - Allow socket option soLinger to be enabled
on TcpTransport. url transport args ?soLinger=0 and ?transport.soLinger (for the broker accepted
connectons) are now supported. a value > -1 enabled and sets the timeout to that value

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
    activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java?rev=1101866&r1=1101865&r2=1101866&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransport.java
Wed May 11 13:17:53 2011
@@ -129,6 +129,7 @@ public class TcpTransport extends Transp
     protected final AtomicReference<CountDownLatch> stoppedLatch = new AtomicReference<CountDownLatch>();
 
     private Map<String, Object> socketOptions;
+    private int soLinger = -1;
     private Boolean keepAlive;
     private Boolean tcpNoDelay;
     private Thread runnerThread;
@@ -358,6 +359,18 @@ public class TcpTransport extends Transp
         this.keepAlive = keepAlive;
     }
 
+    /**
+     * Enable soLinger with the specified soLinger
+     * @param soLinger enabled if > -1
+     */
+    public void setSoLinger(int soLinger) {
+        this.soLinger = soLinger;
+    }
+
+    public int getSoLinger() {
+        return soLinger;
+    }
+
     public Boolean getTcpNoDelay() {
         return tcpNoDelay;
     }
@@ -434,6 +447,10 @@ public class TcpTransport extends Transp
         if (keepAlive != null) {
             sock.setKeepAlive(keepAlive.booleanValue());
         }
+
+        if (soLinger != -1) {
+            sock.setSoLinger(true, soLinger);
+        }
         if (tcpNoDelay != null) {
             sock.setTcpNoDelay(tcpNoDelay.booleanValue());
         }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java?rev=1101866&r1=1101865&r2=1101866&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TransportUriTest.java
Wed May 11 13:17:53 2011
@@ -138,7 +138,7 @@ public class TransportUriTest extends Em
         addCombinationValues("prefix", new Object[] {""});
         // TODO: Add more combinations.
         addCombinationValues("postfix", new Object[]
-            {"?tcpNoDelay=true&keepAlive=true"});
+            {"?tcpNoDelay=true&keepAlive=true&soLinger=0"});
     }
 
     private void testValidOptionsWork(String options, String msg) {

Modified: activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml?rev=1101866&r1=1101865&r2=1101866&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml
(original)
+++ activemq/trunk/activemq-core/src/test/resources/org/apache/activemq/transport/stomp/stomp-auth-broker.xml
Wed May 11 13:17:53 2011
@@ -68,7 +68,7 @@
     </plugins>
     
     <transportConnectors>
-		<transportConnector name="stomp"   uri="stomp://localhost:61613"/>
+		<transportConnector name="stomp"   uri="stomp://localhost:61613?transport.keepAlive=true&amp;transport.soLinger=0"/>
 	</transportConnectors>
     
   </broker>



Mime
View raw message