mirror of https://github.com/apache/activemq.git
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:
parent
3aaa1e73be
commit
0aa5c2a889
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</plugins>
|
||||
|
||||
<transportConnectors>
|
||||
<transportConnector name="stomp" uri="stomp://localhost:61613"/>
|
||||
<transportConnector name="stomp" uri="stomp://localhost:61613?transport.keepAlive=true&transport.soLinger=0"/>
|
||||
</transportConnectors>
|
||||
|
||||
</broker>
|
||||
|
|
Loading…
Reference in New Issue