org.apache.activemq.transport
Class WriteTimeoutFilter

java.lang.Object
  extended by org.apache.activemq.transport.TransportFilter
      extended by org.apache.activemq.transport.WriteTimeoutFilter
All Implemented Interfaces:
Service, Transport, TransportListener

public class WriteTimeoutFilter
extends TransportFilter

This filter implements write timeouts for socket write operations. When using blocking IO, the Java implementation doesn't have an explicit flag to set a timeout, and can cause operations to block forever (or until the TCP stack implementation times out the retransmissions, which is usually around 13-30 minutes).
To enable this transport, in the transport URI, simpley add
transport.soWriteTimeout=.
For example (15 second timeout on write operations to the socket):


 <transportConnector
     name="tcp1"
     uri="tcp://127.0.0.1:61616?transport.soTimeout=10000&transport.soWriteTimeout=15000"
 />
 

For example (enable default timeout on the socket):

 <transportConnector
     name="tcp1"
     uri="tcp://127.0.0.1:61616?transport.soTimeout=10000&transport.soWriteTimeout=15000"
 />
 

Author:
Filip Hanik

Nested Class Summary
protected static class WriteTimeoutFilter.TimeoutThread
           
 
Field Summary
protected static AtomicInteger messageCounter
           
protected static long sleep
           
protected static WriteTimeoutFilter.TimeoutThread timeoutThread
           
protected static ConcurrentLinkedQueue<WriteTimeoutFilter> writers
           
protected  long writeTimeout
           
 
Fields inherited from class org.apache.activemq.transport.TransportFilter
next, transportListener
 
Constructor Summary
WriteTimeoutFilter(Transport next)
           
 
Method Summary
protected static boolean deRegisterWrite(WriteTimeoutFilter filter, boolean fail, IOException iox)
           
static long getSleep()
           
protected  Socket getSocket()
           
protected  TimeStampStream getWriter()
           
 long getWriteTimeout()
           
 void oneway(Object command)
          A one way asynchronous send
protected static void registerWrite(WriteTimeoutFilter filter)
           
static void setSleep(long sleep)
           
 void setWriteTimeout(long writeTimeout)
           
 void start()
           
 void stop()
           
 
Methods inherited from class org.apache.activemq.transport.TransportFilter
asyncRequest, getNext, getReceiveCounter, getRemoteAddress, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, narrow, onCommand, onException, reconnect, request, request, setTransportListener, toString, transportInterupted, transportResumed, updateURIs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

writers

protected static ConcurrentLinkedQueue<WriteTimeoutFilter> writers

messageCounter

protected static AtomicInteger messageCounter

timeoutThread

protected static WriteTimeoutFilter.TimeoutThread timeoutThread

sleep

protected static long sleep

writeTimeout

protected long writeTimeout
Constructor Detail

WriteTimeoutFilter

public WriteTimeoutFilter(Transport next)
Method Detail

oneway

public void oneway(Object command)
            throws IOException
Description copied from interface: Transport
A one way asynchronous send

Specified by:
oneway in interface Transport
Overrides:
oneway in class TransportFilter
Throws:
IOException

getWriteTimeout

public long getWriteTimeout()

setWriteTimeout

public void setWriteTimeout(long writeTimeout)

getSleep

public static long getSleep()

setSleep

public static void setSleep(long sleep)

getWriter

protected TimeStampStream getWriter()

getSocket

protected Socket getSocket()

registerWrite

protected static void registerWrite(WriteTimeoutFilter filter)

deRegisterWrite

protected static boolean deRegisterWrite(WriteTimeoutFilter filter,
                                         boolean fail,
                                         IOException iox)

start

public void start()
           throws Exception
Specified by:
start in interface Service
Overrides:
start in class TransportFilter
Throws:
Exception
See Also:
Service.start()

stop

public void stop()
          throws Exception
Specified by:
stop in interface Service
Overrides:
stop in class TransportFilter
Throws:
Exception
See Also:
Service.stop()


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.