org.codehaus.activemq.transport.tcp
Class TcpTransportChannel

java.lang.Object
  extended byorg.codehaus.activemq.transport.TransportChannelSupport
      extended byorg.codehaus.activemq.transport.tcp.TcpTransportChannel
All Implemented Interfaces:
Runnable, Service, TransportChannel

public class TcpTransportChannel
extends TransportChannelSupport
implements Runnable

A tcp implementation of a TransportChannel

Version:
$Revision: 1.3 $

Field Summary
protected  Socket socket
           
 
Fields inherited from class org.codehaus.activemq.transport.TransportChannelSupport
pendingStop, transportConnected
 
Constructor Summary
protected TcpTransportChannel(WireFormat wireFormat)
          Construct basic helpers
  TcpTransportChannel(WireFormat wireFormat, Socket socket, Executor executor)
           
  TcpTransportChannel(WireFormat wireFormat, URI remoteLocation)
          Connect to a remote Node - e.g.
  TcpTransportChannel(WireFormat wireFormat, URI remoteLocation, URI localLocation)
          Connect to a remote Node - e.g.
 
Method Summary
 void asyncSend(Packet packet)
          Asynchronously send a Packet
 boolean canProcessWireFormatVersion(int version)
          Can this wireformat process packets of this version
protected  Socket createSocket(URI remoteLocation)
          Factory method to create a new socket
protected  Socket createSocket(URI remoteLocation, URI localLocation)
          Factory method to create a new socket
protected  void doAsyncSend(Packet packet)
          Actually performs the async send of a packet
 void forceDisconnect()
          Forces an immediate transport-level disconnect which will be asynchronously reported as an exception to the exceptionListener.
 int getCurrentWireFormatVersion()
           
 Socket getSocket()
           
 int getSoTimeout()
           
protected  void initialiseSocket()
          Configures the socket for use
 boolean isChangeTimeout()
           
 boolean isMulticast()
           
 boolean isUseAsyncSend()
           
 void run()
          reads packets from a Socket
 void setChangeTimeout(boolean changeTimeout)
          Set the changeTimeout flag - if set the timeout value is changed after receiving a packet When receiving a packet, so timeout is set to zero (inifinite) after receiving the first byte, which determines the packet type.
 void setSoTimeout(int soTimeout)
          set the socket so timeout
 void setUseAsyncSend(boolean useAsyncSend)
          set the useAsync flag
 void start()
          start listeneing for events
 void stop()
          close the channel
 String toString()
          pretty print for object
 
Methods inherited from class org.codehaus.activemq.transport.TransportChannelSupport
addTransportStatusEventListener, asyncSendWithReceipt, doConsumePacket, doConsumePacket, doHandleReceipt, doHandleWireFormat, fireStatusEvent, fireStatusEvent, getClientID, getEmbeddedBrokerConnector, getExceptionListener, getLastReceiptTimestamp, getPacketListener, getTransportChannelListener, isPendingStop, isServerSide, isTransportConnected, onAsyncException, removeTransportStatusEventListener, requiresEmbeddedBroker, send, send, setClientID, setExceptionListener, setPacketListener, setPendingStop, setServerSide, setTransportChannelListener, setTransportConnected, stopExecutor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

protected Socket socket
Constructor Detail

TcpTransportChannel

protected TcpTransportChannel(WireFormat wireFormat)
Construct basic helpers

Parameters:
wireFormat -

TcpTransportChannel

public TcpTransportChannel(WireFormat wireFormat,
                           URI remoteLocation)
                    throws JMSException
Connect to a remote Node - e.g. a Broker

Parameters:
wireFormat -
remoteLocation -
Throws:
JMSException

TcpTransportChannel

public TcpTransportChannel(WireFormat wireFormat,
                           URI remoteLocation,
                           URI localLocation)
                    throws JMSException
Connect to a remote Node - e.g. a Broker

Parameters:
wireFormat -
remoteLocation -
localLocation - - e.g. local InetAddress and local port
Throws:
JMSException

TcpTransportChannel

public TcpTransportChannel(WireFormat wireFormat,
                           Socket socket,
                           Executor executor)
                    throws JMSException
Parameters:
wireFormat -
socket -
executor -
Throws:
JMSException
Method Detail

start

public void start()
           throws JMSException
start listeneing for events

Specified by:
start in interface TransportChannel
Throws:
JMSException - if an error occurs

stop

public void stop()
close the channel

Specified by:
stop in interface TransportChannel
Overrides:
stop in class TransportChannelSupport

forceDisconnect

public void forceDisconnect()
Description copied from interface: TransportChannel
Forces an immediate transport-level disconnect which will be asynchronously reported as an exception to the exceptionListener. If the channel isn't connected, the call will be ignored.

Specified by:
forceDisconnect in interface TransportChannel

asyncSend

public void asyncSend(Packet packet)
               throws JMSException
Asynchronously send a Packet

Specified by:
asyncSend in interface TransportChannel
Parameters:
packet -
Throws:
JMSException

isMulticast

public boolean isMulticast()
Specified by:
isMulticast in interface TransportChannel
Overrides:
isMulticast in class TransportChannelSupport
Returns:
false

run

public void run()
reads packets from a Socket

Specified by:
run in interface Runnable

toString

public String toString()
pretty print for object

Returns:
String representation of this object

getSocket

public Socket getSocket()
Returns:
the socket used by the TcpTransportChannel

canProcessWireFormatVersion

public boolean canProcessWireFormatVersion(int version)
Can this wireformat process packets of this version

Specified by:
canProcessWireFormatVersion in interface TransportChannel
Overrides:
canProcessWireFormatVersion in class TransportChannelSupport
Parameters:
version - the version number to test
Returns:
true if can accept the version

getCurrentWireFormatVersion

public int getCurrentWireFormatVersion()
Specified by:
getCurrentWireFormatVersion in interface TransportChannel
Overrides:
getCurrentWireFormatVersion in class TransportChannelSupport
Returns:
the current version of this wire format

isChangeTimeout

public boolean isChangeTimeout()
Returns:
true if the so timeout is changed when receiving packets

setChangeTimeout

public void setChangeTimeout(boolean changeTimeout)
Set the changeTimeout flag - if set the timeout value is changed after receiving a packet When receiving a packet, so timeout is set to zero (inifinite) after receiving the first byte, which determines the packet type. resetting the value is an overhead, but on some operating systems (Solaris), detecting that a socket peer has disconnected is only possible with so timeout set to a non-zero value

Parameters:
changeTimeout -

isUseAsyncSend

public boolean isUseAsyncSend()
Returns:
true if packets are enqueued to a separate queue before dispatching

setUseAsyncSend

public void setUseAsyncSend(boolean useAsyncSend)
set the useAsync flag

Parameters:
useAsyncSend -

getSoTimeout

public int getSoTimeout()
Returns:
the current so timeout used on the socket

setSoTimeout

public void setSoTimeout(int soTimeout)
set the socket so timeout

Parameters:
soTimeout -

doAsyncSend

protected void doAsyncSend(Packet packet)
                    throws JMSException
Actually performs the async send of a packet

Overrides:
doAsyncSend in class TransportChannelSupport
Parameters:
packet -
Throws:
JMSException

initialiseSocket

protected void initialiseSocket()
                         throws IOException
Configures the socket for use

Throws:
IOException

createSocket

protected Socket createSocket(URI remoteLocation)
                       throws UnknownHostException,
                              IOException
Factory method to create a new socket

Parameters:
remoteLocation - the URI to connect to
Returns:
the newly created socket
Throws:
UnknownHostException
IOException

createSocket

protected Socket createSocket(URI remoteLocation,
                              URI localLocation)
                       throws IOException,
                              UnknownHostException
Factory method to create a new socket

Parameters:
remoteLocation -
localLocation -
Returns:
@throws IOException
Throws:
IOException
UnknownHostException


Copyright © 2004-2005 Protique, Ltd.. All Rights Reserved.