From 642d38cd8ca74e4fdc70de0fc4d28f3997d4752c Mon Sep 17 00:00:00 2001 From: "Hiram R. Chirino" Date: Wed, 5 Sep 2007 21:51:40 +0000 Subject: [PATCH] Fix for https://issues.apache.org/activemq/browse/AMQ-1156 We now actually update the tcpNoDelay setting on the socket once the wireformat options are negociated. This allows the client to control if his socket and the server's socket use the option. By default tcpNoDelay is enabled. the client should use a URL like -Durl=tcp://localhost:61616?wireFormat.tcpNoDelayEnabled=false to disable tcpNoDelay on both the client and the server socket. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@573080 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/transport/WireFormatNegotiator.java | 5 +++++ .../org/apache/activemq/transport/tcp/TcpTransport.java | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/WireFormatNegotiator.java b/activemq-core/src/main/java/org/apache/activemq/transport/WireFormatNegotiator.java index 1f9ca710dc..dc9910620e 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/WireFormatNegotiator.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/WireFormatNegotiator.java @@ -18,6 +18,7 @@ package org.apache.activemq.transport; import java.io.IOException; import java.io.InterruptedIOException; +import java.net.Socket; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -111,6 +112,10 @@ public class WireFormatNegotiator extends TransportFilter { } wireFormat.renegotiateWireFormat(info); + Socket socket = next.narrow(Socket.class); + if (socket != null) { + socket.setTcpNoDelay(wireFormat.isTcpNoDelayEnabled()); + } if (LOG.isDebugEnabled()) { LOG.debug(this + " after negotiation: " + wireFormat); 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 9811f90a30..08cc539e97 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 @@ -483,5 +483,13 @@ public class TcpTransport extends TransportThreadSupport implements Transport, S } return null; } + + @Override + public T narrow(Class target) { + if (target == Socket.class) { + return target.cast(socket); + } + return super.narrow(target); + } }