Class TcpTransportServer
java.lang.Object
org.apache.activemq.util.ServiceSupport
org.apache.activemq.transport.TransportServerSupport
org.apache.activemq.transport.TransportServerThreadSupport
org.apache.activemq.transport.tcp.TcpTransportServer
- All Implemented Interfaces:
Runnable,Service,TransportServer,ServiceListener
- Direct Known Subclasses:
NIOSSLTransportServer,SslTransportServer
A TCP based implementation of
TransportServer-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected intprotected final AtomicIntegerprotected booleanSpecifies if the TransportLogger will be manageable by JMX or not.protected intprotected StringName of the LogWriter implementation to use.protected intThe maximum number of sockets allowed for this serverprotected final AtomicLongprotected longprotected longprotected intprotected Selectorprotected ServerSocketprotected final ServerSocketFactoryprotected intprotected Threadprotected final BlockingQueue<Socket>protected intprotected booleanstartLogging=true -> the TransportLogger object of the Transport stack will initially write messages to the log.protected booleantrace=true -> the Transport stack where this TcpTransport object will be, will have a TransportLogger layer trace=false -> the Transport stack where this TcpTransport object will be, will NOT have a TransportLogger layer, and therefore will never be able to print logging messages.protected final TcpTransportFactoryprotected booleanprotected booleanprotected WireFormatFactoryFields inherited from class org.apache.activemq.transport.TransportServerSupport
transportOptions -
Constructor Summary
ConstructorsConstructorDescriptionTcpTransportServer(TcpTransportFactory transportFactory, URI location, ServerSocketFactory serverSocketFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidbind()protected TcpTransportServer.TransportInfoconfigureTransport(TcpTransportServer server, Socket socket) protected TransportcreateTransport(Socket socket, WireFormat format) Allow derived classes to override the Transport implementation that this transport server creates.protected final voiddoHandleSocket(Socket socket) protected voiddoStart()protected voiddoStop(ServiceStopper stopper) intintintlongintlonglongintintintprotected voidhandleSocket(Socket socket) booleanSome protocols allow link stealing by default (if 2 connections have the same clientID - the youngest wins).booleanbooleanFor TransportServers that provide SSL connections to their connected peers they should return true here if and only if they populate the ConnectionInfo command presented to the Broker with the peers certificate chain so that the broker knows it can use that information to authenticate the connected peer.booleanbooleanisTrace()booleanvoidprotected StringresolveHostName(ServerSocket socket, InetAddress bindAddress) voidrun()pull Sockets from the ServerSocketvoidsetAllowLinkStealing(boolean allowLinkStealing) voidsetBacklog(int backlog) voidsetBrokerInfo(BrokerInfo brokerInfo) Associates a broker info with the transport server so that the transport can do discovery advertisements of the broker.voidsetConnectionTimeout(int connectionTimeout) voidsetDynamicManagement(boolean useJmx) voidsetJmxPort(int jmxPort) voidsetLogWriterName(String logFormat) voidsetMaximumConnections(int maximumConnections) voidsetMaxInactivityDuration(long maxInactivityDuration) voidsetMaxInactivityDurationInitalDelay(long maxInactivityDurationInitalDelay) voidsetMinmumWireFormatVersion(int minmumWireFormatVersion) voidsetSocketBufferSize(int socketBufferSize) voidsetSoTimeout(int soTimeout) voidsetStartLogging(boolean startLogging) voidsetTrace(boolean trace) voidsetUseQueueForAccept(boolean useQueueForAccept) voidsetWireFormatFactory(WireFormatFactory wireFormatFactory) voidvoidtoString()Methods inherited from class org.apache.activemq.transport.TransportServerThreadSupport
getStackSize, isDaemon, isJoinOnStop, setDaemon, setJoinOnStop, setStackSizeMethods inherited from class org.apache.activemq.transport.TransportServerSupport
getAcceptListener, getBindLocation, getConnectURI, onAcceptError, setAcceptListener, setBindLocation, setConnectURI, setTransportOptionMethods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
-
Field Details
-
serverSocket
-
selector
-
backlog
protected int backlog -
wireFormatFactory
-
transportFactory
-
maxInactivityDuration
protected long maxInactivityDuration -
maxInactivityDurationInitalDelay
protected long maxInactivityDurationInitalDelay -
minmumWireFormatVersion
protected int minmumWireFormatVersion -
useQueueForAccept
protected boolean useQueueForAccept -
allowLinkStealing
protected boolean allowLinkStealing -
verifyHostName
protected boolean verifyHostName -
trace
protected boolean tracetrace=true -> the Transport stack where this TcpTransport object will be, will have a TransportLogger layer trace=false -> the Transport stack where this TcpTransport object will be, will NOT have a TransportLogger layer, and therefore will never be able to print logging messages. This parameter is most probably set in Connection or TransportConnector URIs. -
soTimeout
protected int soTimeout -
socketBufferSize
protected int socketBufferSize -
connectionTimeout
protected int connectionTimeout -
logWriterName
Name of the LogWriter implementation to use. Names are mapped to classes in the resources/META-INF/services/org/apache/activemq/transport/logwriters directory. This parameter is most probably set in Connection or TransportConnector URIs. -
dynamicManagement
protected boolean dynamicManagementSpecifies if the TransportLogger will be manageable by JMX or not. Also, as long as there is at least 1 TransportLogger which is manageable, a TransportLoggerControl MBean will me created. -
startLogging
protected boolean startLoggingstartLogging=true -> the TransportLogger object of the Transport stack will initially write messages to the log. startLogging=false -> the TransportLogger object of the Transport stack will initially NOT write messages to the log. This parameter only has an effect if trace == true. This parameter is most probably set in Connection or TransportConnector URIs. -
jmxPort
protected int jmxPort -
serverSocketFactory
-
socketQueue
-
socketHandlerThread
-
maximumConnections
protected int maximumConnectionsThe maximum number of sockets allowed for this server -
maximumConnectionsExceededCount
-
currentTransportCount
-
-
Constructor Details
-
TcpTransportServer
public TcpTransportServer(TcpTransportFactory transportFactory, URI location, ServerSocketFactory serverSocketFactory) throws IOException, URISyntaxException - Throws:
IOExceptionURISyntaxException
-
-
Method Details
-
bind
- Throws:
IOException
-
getWireFormatFactory
- Returns:
- Returns the wireFormatFactory.
-
setWireFormatFactory
- Parameters:
wireFormatFactory- The wireFormatFactory to set.
-
setBrokerInfo
Associates a broker info with the transport server so that the transport can do discovery advertisements of the broker.- Specified by:
setBrokerInfoin interfaceTransportServer- Parameters:
brokerInfo-
-
getMaxInactivityDuration
public long getMaxInactivityDuration() -
setMaxInactivityDuration
public void setMaxInactivityDuration(long maxInactivityDuration) -
getMaxInactivityDurationInitalDelay
public long getMaxInactivityDurationInitalDelay() -
setMaxInactivityDurationInitalDelay
public void setMaxInactivityDurationInitalDelay(long maxInactivityDurationInitalDelay) -
getMinmumWireFormatVersion
public int getMinmumWireFormatVersion() -
setMinmumWireFormatVersion
public void setMinmumWireFormatVersion(int minmumWireFormatVersion) -
isTrace
public boolean isTrace() -
setTrace
public void setTrace(boolean trace) -
getLogWriterName
-
setLogWriterName
-
isDynamicManagement
public boolean isDynamicManagement() -
setDynamicManagement
public void setDynamicManagement(boolean useJmx) -
setJmxPort
public void setJmxPort(int jmxPort) -
getJmxPort
public int getJmxPort() -
isStartLogging
public boolean isStartLogging() -
setStartLogging
public void setStartLogging(boolean startLogging) -
getBacklog
public int getBacklog()- Returns:
- the backlog
-
setBacklog
public void setBacklog(int backlog) - Parameters:
backlog- the backlog to set
-
isUseQueueForAccept
public boolean isUseQueueForAccept()- Returns:
- the useQueueForAccept
-
setUseQueueForAccept
public void setUseQueueForAccept(boolean useQueueForAccept) - Parameters:
useQueueForAccept- the useQueueForAccept to set
-
run
public void run()pull Sockets from the ServerSocket -
createTransport
Allow derived classes to override the Transport implementation that this transport server creates.- Parameters:
socket-format-- Returns:
- a new Transport instance.
- Throws:
IOException
-
toString
-
resolveHostName
protected String resolveHostName(ServerSocket socket, InetAddress bindAddress) throws UnknownHostException - Parameters:
socket-bindAddress-- Returns:
- real hostName
- Throws:
UnknownHostException
-
doStart
- Overrides:
doStartin classTransportServerThreadSupport- Throws:
Exception
-
doStop
- Overrides:
doStopin classTransportServerThreadSupport- Throws:
Exception
-
getSocketAddress
- Specified by:
getSocketAddressin interfaceTransportServer- Returns:
- The socket address that this transport is accepting connections on or null if this does not or is not currently accepting connections on a socket.
-
handleSocket
-
doHandleSocket
-
configureTransport
protected TcpTransportServer.TransportInfo configureTransport(TcpTransportServer server, Socket socket) throws Exception - Throws:
Exception
-
getSoTimeout
public int getSoTimeout() -
setSoTimeout
public void setSoTimeout(int soTimeout) -
getSocketBufferSize
public int getSocketBufferSize() -
setSocketBufferSize
public void setSocketBufferSize(int socketBufferSize) -
getConnectionTimeout
public int getConnectionTimeout() -
setConnectionTimeout
public void setConnectionTimeout(int connectionTimeout) -
getMaximumConnections
public int getMaximumConnections()- Returns:
- the maximumConnections
-
setMaximumConnections
public void setMaximumConnections(int maximumConnections) - Parameters:
maximumConnections- the maximumConnections to set
-
getCurrentTransportCount
-
started
- Specified by:
startedin interfaceServiceListener
-
stopped
- Specified by:
stoppedin interfaceServiceListener
-
isSslServer
public boolean isSslServer()Description copied from interface:TransportServerFor TransportServers that provide SSL connections to their connected peers they should return true here if and only if they populate the ConnectionInfo command presented to the Broker with the peers certificate chain so that the broker knows it can use that information to authenticate the connected peer.- Specified by:
isSslServerin interfaceTransportServer- Returns:
- true if this transport server provides SSL level security over its connections.
-
isAllowLinkStealing
public boolean isAllowLinkStealing()Description copied from interface:TransportServerSome protocols allow link stealing by default (if 2 connections have the same clientID - the youngest wins). This is the default for AMQP and MQTT. However, JMS 1.1 spec requires the opposite- Specified by:
isAllowLinkStealingin interfaceTransportServer- Overrides:
isAllowLinkStealingin classTransportServerSupport- Returns:
- true if allow link stealing is enabled.
-
setAllowLinkStealing
public void setAllowLinkStealing(boolean allowLinkStealing) - Overrides:
setAllowLinkStealingin classTransportServerSupport
-
getMaxConnectionExceededCount
public long getMaxConnectionExceededCount()- Specified by:
getMaxConnectionExceededCountin interfaceTransportServer
-
resetStatistics
public void resetStatistics()- Specified by:
resetStatisticsin interfaceTransportServer
-