Class NettyConnection
java.lang.Object
org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnection
- All Implemented Interfaces:
Connection
- Direct Known Subclasses:
NettyServerConnection
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNettyConnection(Map<String, Object> configuration, io.netty.channel.Channel channel, BaseConnectionLifeCycleListener<?> listener, boolean batchingEnabled, boolean directDeliver) -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanblockUntilWritable(long timeout, TimeUnit timeUnit) Causes the current thread to wait until the connection is writable unless the specified waiting time elapses.final voidCalled periodically to flush any data in the batch bufferfinal voidclose()Closes the connection.createTransportBuffer(int size) Create a new ActiveMQBuffer of the given size.final voidfireReady(boolean ready) voidflush()Request to flush any previous written buffers into the wire.final voidThis should close the internal channel without calling any listeners.final io.netty.channel.ChannelThis is exposed so users would have the option to look at any data through interceptorsfinal TransportConfigurationGenerates aTransportConfigurationto be used to connect to the same target this is connected to.final ActiveMQPrincipalio.netty.channel.EventLoopfinal ObjectgetID()Returns the unique id of this wire.final StringReturns a string representation of the local address this connection is connected to.final io.netty.channel.Channelfinal RemotingConnectionfinal StringReturns the string representation of the remote address this connection is connected to.final booleanbooleanisOpen()booleanisSameTarget(TransportConfiguration... configs) final booleanthe InVM Connection has some special handling as it doesn't use Netty ProtocolChannel we will use this method Instead of using instanceoffinal booleanisWritable(ReadyListener callback) final voidsetAutoRead(boolean autoRead) This will disable reading from the channel.final voidsetProtocolConnection(RemotingConnection protocolConnection) final StringtoString()final voidwrite(ActiveMQBuffer buffer) writes the buffer to the connection with no flushing or batchingvoidwrite(ActiveMQBuffer buffer, boolean requestFlush) writes the buffer to the connection and if flush is true request to flush the buffer (and any previous un-flushed ones) into the wire.final voidwrite(ActiveMQBuffer buffer, boolean flush, boolean batched) writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.final voidwrite(ActiveMQBuffer buffer, boolean flush, boolean batched, io.netty.channel.ChannelFutureListener futureListener) writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.activemq.artemis.spi.core.remoting.Connection
disconnect, getRouter, getSNIHostName
-
Field Details
-
channel
protected final io.netty.channel.Channel channel
-
-
Constructor Details
-
NettyConnection
public NettyConnection(Map<String, Object> configuration, io.netty.channel.Channel channel, BaseConnectionLifeCycleListener<?> listener, boolean batchingEnabled, boolean directDeliver)
-
-
Method Details
-
getEventLoop
public io.netty.channel.EventLoop getEventLoop()- Specified by:
getEventLoopin interfaceConnection
-
getNettyChannel
public final io.netty.channel.Channel getNettyChannel() -
setAutoRead
public final void setAutoRead(boolean autoRead) Description copied from interface:ConnectionThis will disable reading from the channel. This is basically the same as blocking the reading.- Specified by:
setAutoReadin interfaceConnection
-
isWritable
- Specified by:
isWritablein interfaceConnection
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceConnection
-
fireReady
public final void fireReady(boolean ready) - Specified by:
fireReadyin interfaceConnection
-
forceClose
public final void forceClose()Description copied from interface:ConnectionThis should close the internal channel without calling any listeners. This is to avoid a situation where the broker is busy writing on an internal thread. This should close the socket releasing any pending threads.- Specified by:
forceClosein interfaceConnection
-
getChannel
public final io.netty.channel.Channel getChannel()This is exposed so users would have the option to look at any data through interceptors -
getProtocolConnection
- Specified by:
getProtocolConnectionin interfaceConnection
-
setProtocolConnection
- Specified by:
setProtocolConnectionin interfaceConnection
-
close
public final void close()Description copied from interface:ConnectionCloses the connection.- Specified by:
closein interfaceConnection
-
createTransportBuffer
Description copied from interface:ConnectionCreate a new ActiveMQBuffer of the given size.- Specified by:
createTransportBufferin interfaceConnection- Parameters:
size- the size of buffer to create- Returns:
- the new buffer
-
getID
Description copied from interface:ConnectionReturns the unique id of this wire.- Specified by:
getIDin interfaceConnection- Returns:
- the unique id of this wire
-
checkFlushBatchBuffer
public final void checkFlushBatchBuffer()Description copied from interface:ConnectionCalled periodically to flush any data in the batch buffer- Specified by:
checkFlushBatchBufferin interfaceConnection
-
write
Description copied from interface:Connectionwrites the buffer to the connection with no flushing or batching- Specified by:
writein interfaceConnection- Parameters:
buffer- the buffer to write
-
write
Description copied from interface:Connectionwrites the buffer to the connection and if flush is true request to flush the buffer (and any previous un-flushed ones) into the wire.- Specified by:
writein interfaceConnection- Parameters:
buffer- the buffer to writerequestFlush- whether to request flush onto the wire
-
flush
public void flush()Description copied from interface:ConnectionRequest to flush any previous written buffers into the wire.- Specified by:
flushin interfaceConnection
-
write
Description copied from interface:Connectionwrites the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.- Specified by:
writein interfaceConnection- Parameters:
buffer- the buffer to writeflush- whether to flush the buffers onto the wirebatched- whether the packet is allowed to batched for better performance
-
blockUntilWritable
Description copied from interface:ConnectionCauses the current thread to wait until the connection is writable unless the specified waiting time elapses. The available capacity of the connection could change concurrently hence this method is suitable to perform precise flow-control only in a single writer case, while its precision decrease inversely proportional with the rate and the number of concurrent writers. If the current thread is not allowed to block the timeout will be ignored dependently on the connection type.- Specified by:
blockUntilWritablein interfaceConnection- Parameters:
timeout- the maximum time to waittimeUnit- the time unit of the timeout argument- Returns:
trueif the connection is writable,falseotherwise
-
write
public final void write(ActiveMQBuffer buffer, boolean flush, boolean batched, io.netty.channel.ChannelFutureListener futureListener) Description copied from interface:Connectionwrites the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.- Specified by:
writein interfaceConnection- Parameters:
buffer- the buffer to writeflush- whether to flush the buffers onto the wirebatched- whether the packet is allowed to batched for better performance
-
getRemoteAddress
Description copied from interface:ConnectionReturns the string representation of the remote address this connection is connected to.- Specified by:
getRemoteAddressin interfaceConnection- Returns:
- the string representation of the remote address this connection is connected to
-
getLocalAddress
Description copied from interface:ConnectionReturns a string representation of the local address this connection is connected to. This is useful when the server is configured at 0.0.0.0 (or multiple IPs). This will give you the actual IP that's being used.- Specified by:
getLocalAddressin interfaceConnection- Returns:
- the local address
-
isDirectDeliver
public final boolean isDirectDeliver()- Specified by:
isDirectDeliverin interfaceConnection
-
getDefaultActiveMQPrincipal
- Specified by:
getDefaultActiveMQPrincipalin interfaceConnection
-
getConnectorConfig
Description copied from interface:ConnectionGenerates aTransportConfigurationto be used to connect to the same target this is connected to.- Specified by:
getConnectorConfigin interfaceConnection- Returns:
- TransportConfiguration
-
isUsingProtocolHandling
public final boolean isUsingProtocolHandling()Description copied from interface:Connectionthe InVM Connection has some special handling as it doesn't use Netty ProtocolChannel we will use this method Instead of using instanceof- Specified by:
isUsingProtocolHandlingin interfaceConnection
-
isSameTarget
- Specified by:
isSameTargetin interfaceConnection
-
toString
-