mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@742458 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4dda0d8353
commit
15065b71c7
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.activemq.command.CommandTypes;
|
||||
import org.apache.activemq.command.DataStructure;
|
||||
|
@ -62,6 +63,8 @@ public final class OpenWireFormat implements WireFormat {
|
|||
private DataByteArrayInputStream bytesIn = new DataByteArrayInputStream();
|
||||
private WireFormatInfo preferedWireFormatInfo;
|
||||
|
||||
private AtomicBoolean receivingMessage = new AtomicBoolean(false);
|
||||
|
||||
public OpenWireFormat() {
|
||||
this(DEFAULT_VERSION);
|
||||
}
|
||||
|
@ -350,6 +353,7 @@ public final class OpenWireFormat implements WireFormat {
|
|||
|
||||
public Object doUnmarshal(DataInput dis) throws IOException {
|
||||
byte dataType = dis.readByte();
|
||||
receivingMessage.set(true);
|
||||
if (dataType != NULL_TYPE) {
|
||||
DataStreamMarshaller dsm = (DataStreamMarshaller)dataMarshallers[dataType & 0xFF];
|
||||
if (dsm == null) {
|
||||
|
@ -363,8 +367,10 @@ public final class OpenWireFormat implements WireFormat {
|
|||
} else {
|
||||
dsm.looseUnmarshal(this, data, dis);
|
||||
}
|
||||
receivingMessage.set(false);
|
||||
return data;
|
||||
} else {
|
||||
receivingMessage.set(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -590,6 +596,10 @@ public final class OpenWireFormat implements WireFormat {
|
|||
return preferedWireFormatInfo;
|
||||
}
|
||||
|
||||
public boolean inReceive() {
|
||||
return receivingMessage.get();
|
||||
}
|
||||
|
||||
public void renegotiateWireFormat(WireFormatInfo info) throws IOException {
|
||||
|
||||
if (preferedWireFormatInfo == null) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import org.apache.activemq.command.KeepAliveInfo;
|
||||
import org.apache.activemq.command.WireFormatInfo;
|
||||
import org.apache.activemq.thread.SchedulerTimerTask;
|
||||
import org.apache.activemq.wireformat.WireFormat;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -62,6 +63,8 @@ public class InactivityMonitor extends TransportFilter {
|
|||
private long writeCheckTime;
|
||||
private long initialDelayTime;
|
||||
|
||||
private WireFormat wireFormat;
|
||||
|
||||
private final Runnable readChecker = new Runnable() {
|
||||
long lastRunTime;
|
||||
public void run() {
|
||||
|
@ -104,8 +107,9 @@ public class InactivityMonitor extends TransportFilter {
|
|||
}
|
||||
};
|
||||
|
||||
public InactivityMonitor(Transport next) {
|
||||
public InactivityMonitor(Transport next, WireFormat wireFormat) {
|
||||
super(next);
|
||||
this.wireFormat = wireFormat;
|
||||
}
|
||||
|
||||
public void stop() throws Exception {
|
||||
|
@ -149,7 +153,7 @@ public class InactivityMonitor extends TransportFilter {
|
|||
}
|
||||
|
||||
final void readCheck() {
|
||||
if (inReceive.get()) {
|
||||
if (inReceive.get() || wireFormat.inReceive()) {
|
||||
if (LOG.isTraceEnabled()) {
|
||||
LOG.trace("A receive is in progress");
|
||||
}
|
||||
|
|
|
@ -202,4 +202,11 @@ public class StompWireFormat implements WireFormat {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean inReceive() {
|
||||
//TODO implement the inactivity monitor
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class SslTransportFactory extends TcpTransportFactory {
|
|||
}
|
||||
}
|
||||
|
||||
transport = new InactivityMonitor(transport);
|
||||
transport = new InactivityMonitor(transport, format);
|
||||
|
||||
// Only need the WireFormatNegotiator if using openwire
|
||||
if (format instanceof OpenWireFormat) {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class TcpTransportFactory extends TransportFactory {
|
|||
}
|
||||
|
||||
if (isUseInactivityMonitor(transport)) {
|
||||
transport = new InactivityMonitor(transport);
|
||||
transport = new InactivityMonitor(transport, format);
|
||||
}
|
||||
|
||||
// Only need the WireFormatNegotiator if using openwire
|
||||
|
|
|
@ -91,7 +91,7 @@ public class UdpTransportFactory extends TransportFactory {
|
|||
}
|
||||
}
|
||||
|
||||
transport = new InactivityMonitor(transport);
|
||||
transport = new InactivityMonitor(transport, format);
|
||||
|
||||
if (format instanceof OpenWireFormat) {
|
||||
transport = configureClientSideNegotiator(transport, format, udpTransport);
|
||||
|
@ -123,7 +123,7 @@ public class UdpTransportFactory extends TransportFactory {
|
|||
transport = TransportLoggerFactory.getInstance().createTransportLogger(transport);
|
||||
}
|
||||
|
||||
transport = new InactivityMonitor(transport);
|
||||
transport = new InactivityMonitor(transport, format);
|
||||
|
||||
if (!acceptServer && format instanceof OpenWireFormat) {
|
||||
transport = configureClientSideNegotiator(transport, format, udpTransport);
|
||||
|
|
|
@ -132,7 +132,7 @@ public class UdpTransportServer extends TransportServerSupport {
|
|||
}
|
||||
|
||||
protected Transport configureTransport(Transport transport) {
|
||||
transport = new InactivityMonitor(transport);
|
||||
transport = new InactivityMonitor(transport, serverTransport.getWireFormat());
|
||||
getAcceptListener().onAccept(transport);
|
||||
return transport;
|
||||
}
|
||||
|
|
|
@ -75,4 +75,11 @@ public class ObjectStreamWireFormat implements WireFormat {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public boolean inReceive() {
|
||||
// TODO implement the inactivity monitor
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -61,4 +61,9 @@ public interface WireFormat {
|
|||
*/
|
||||
int getVersion();
|
||||
|
||||
/**
|
||||
* @return true if message is being received
|
||||
*/
|
||||
boolean inReceive();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue