Class InVMConnection
- java.lang.Object
-
- org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnection
-
- All Implemented Interfaces:
Connection
public class InVMConnection extends Object implements Connection
-
-
Constructor Summary
Constructors Constructor Description InVMConnection(int serverID, String id, BufferHandler handler, BaseConnectionLifeCycleListener listener, Executor executor)InVMConnection(int serverID, String id, BufferHandler handler, BaseConnectionLifeCycleListener listener, Executor executor, ActiveMQPrincipal defaultActiveMQPrincipal)InVMConnection(int serverID, BufferHandler handler, BaseConnectionLifeCycleListener listener, Executor executor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckFlushBatchBuffer()Called periodically to flush any data in the batch buffervoidclose()Closes the connection.ActiveMQBuffercreateTransportBuffer(int size)Create a new ActiveMQBuffer of the given size.voidfireReady(boolean ready)voidforceClose()This should close the internal channel without calling any listeners.intgetBatchingBufferSize()TransportConfigurationgetConnectorConfig()Generates aTransportConfigurationto be used to connect to the same target this is connected to.ActiveMQPrincipalgetDefaultActiveMQPrincipal()ExecutorgetExecutor()ObjectgetID()returns the unique id of this wire.StringgetLocalAddress()Returns a string representation of the local address this connection is connected to.RemotingConnectiongetProtocolConnection()StringgetRemoteAddress()Returns a string representation of the remote address this connection is connected to.booleanisDirectDeliver()booleanisOpen()booleanisSameTarget(TransportConfiguration... configs)booleanisUsingProtocolHandling()the InVM Connection has some special handling as it doesn't use Netty ProtocolChannel we will use this method Instead of using instanceofbooleanisWritable(ReadyListener listener)voidsetAutoRead(boolean autoRead)This will disable reading from the channel.voidsetDirectDeliver(boolean directDeliver)voidsetEnableBufferPooling(boolean enableBufferPooling)static voidsetFlushEnabled(boolean enable)voidsetProtocolConnection(RemotingConnection connection)StringtoString()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.voidwrite(ActiveMQBuffer buffer, boolean flush, boolean batch)writes the buffer to the connection and if flush is true returns only when the buffer has been physically written to the connection.voidwrite(ActiveMQBuffer buffer, boolean flush, boolean batch, 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, wait
-
Methods inherited from interface org.apache.activemq.artemis.spi.core.remoting.Connection
blockUntilWritable, flush, getRouter, getSNIHostName
-
-
-
-
Constructor Detail
-
InVMConnection
public InVMConnection(int serverID, BufferHandler handler, BaseConnectionLifeCycleListener listener, Executor executor)
-
InVMConnection
public InVMConnection(int serverID, String id, BufferHandler handler, BaseConnectionLifeCycleListener listener, Executor executor)
-
InVMConnection
public InVMConnection(int serverID, String id, BufferHandler handler, BaseConnectionLifeCycleListener listener, Executor executor, ActiveMQPrincipal defaultActiveMQPrincipal)
-
-
Method Detail
-
setEnableBufferPooling
public void setEnableBufferPooling(boolean enableBufferPooling)
-
forceClose
public 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
-
isWritable
public boolean isWritable(ReadyListener listener)
- Specified by:
isWritablein interfaceConnection
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfaceConnection
-
fireReady
public void fireReady(boolean ready)
- Specified by:
fireReadyin interfaceConnection
-
getProtocolConnection
public RemotingConnection getProtocolConnection()
- Specified by:
getProtocolConnectionin interfaceConnection
-
setProtocolConnection
public void setProtocolConnection(RemotingConnection connection)
- Specified by:
setProtocolConnectionin interfaceConnection
-
close
public void close()
Description copied from interface:ConnectionCloses the connection.- Specified by:
closein interfaceConnection
-
setAutoRead
public 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
-
createTransportBuffer
public ActiveMQBuffer createTransportBuffer(int size)
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
public Object getID()
Description copied from interface:Connectionreturns the unique id of this wire.- Specified by:
getIDin interfaceConnection- Returns:
- the id
-
checkFlushBatchBuffer
public void checkFlushBatchBuffer()
Description copied from interface:ConnectionCalled periodically to flush any data in the batch buffer- Specified by:
checkFlushBatchBufferin interfaceConnection
-
write
public void write(ActiveMQBuffer buffer, boolean requestFlush)
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
-
write
public void write(ActiveMQBuffer buffer)
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
public void write(ActiveMQBuffer buffer, boolean flush, boolean batch)
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 wirebatch- whether the packet is allowed to batched for better performance
-
write
public void write(ActiveMQBuffer buffer, boolean flush, boolean batch, 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 wirebatch- whether the packet is allowed to batched for better performance
-
getRemoteAddress
public String getRemoteAddress()
Description copied from interface:ConnectionReturns a string representation of the remote address this connection is connected to.- Specified by:
getRemoteAddressin interfaceConnection- Returns:
- the remote address
-
getLocalAddress
public String 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
-
getBatchingBufferSize
public int getBatchingBufferSize()
-
isUsingProtocolHandling
public 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- Returns:
-
getDefaultActiveMQPrincipal
public ActiveMQPrincipal getDefaultActiveMQPrincipal()
- Specified by:
getDefaultActiveMQPrincipalin interfaceConnection
-
setFlushEnabled
public static void setFlushEnabled(boolean enable)
-
getExecutor
public Executor getExecutor()
-
getConnectorConfig
public TransportConfiguration 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
-
isDirectDeliver
public boolean isDirectDeliver()
- Specified by:
isDirectDeliverin interfaceConnection
-
setDirectDeliver
public void setDirectDeliver(boolean directDeliver)
-
isSameTarget
public boolean isSameTarget(TransportConfiguration... configs)
- Specified by:
isSameTargetin interfaceConnection
-
-