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

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1101866 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-05-11 13:17:53 +00:00
parent 3aaa1e73be
commit 0aa5c2a889
3 changed files with 19 additions and 2 deletions

View File

@ -129,6 +129,7 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S
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 TransportThreadSupport implements Transport, S
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 TransportThreadSupport implements Transport, S
if (keepAlive != null) {
sock.setKeepAlive(keepAlive.booleanValue());
}
if (soLinger != -1) {
sock.setSoLinger(true, soLinger);
}
if (tcpNoDelay != null) {
sock.setTcpNoDelay(tcpNoDelay.booleanValue());
}

View File

@ -138,7 +138,7 @@ public class TransportUriTest extends EmbeddedBrokerTestSupport {
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) {

View File

@ -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>