Class ChannelImpl
java.lang.Object
org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl
- All Implemented Interfaces:
Channel
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionChannelImpl(CoreRemotingConnection connection, long id, int confWindowSize, List<Interceptor> interceptors) -
Method Summary
Modifier and TypeMethodDescriptionvoidclears any commands from the cache that are yet to be confirmed.voidclose()Closes this channel.voidsends a confirmation of a packet being received.voidvoidflushes any confirmations on to the connection.voidSimilarly toflushConnectiononChannel.send(Packet, boolean), it requests any un-flushed previous sent packets to be flushed to the underlying connection.protected ResponseCachegetCache()intReturns the confirmation window size this channel is using.Returns theCoreRemotingConnectionbeing used by the channel.Gets theChannelHandlerthat this channel should forward received packets to.longgetID()Returns the id of this channel.intReturns the last confirmed packet command id.getLock()Returns the channel lock.intThis number increases every time the channel reconnects successfully.voidhandleAsyncResponse(Packet packet) voidhandlePacket(Packet packet) Called byCoreRemotingConnectionwhen a packet is received.static StringinvokeInterceptors(Packet packet, List<Interceptor> interceptors, RemotingConnection connection) Returns the name of the interceptor that returnedfalseornullif no interceptors returnedfalse.booleanisLocked()queries if this channel is locked.voidlock()locks the channel.voidreplayCommands(int otherLastConfirmedCommandID) resends any packets that have not received confirmations yet.booleanvoidforces anyChannel.sendBlocking(Packet, byte)request to return with an exception.voidreturnBlocking(Throwable cause) forces anyChannel.sendBlocking(Packet, byte)request to return with an exception.booleanSends a packet on this channel.booleanSends a packet on this channel, but request it to be flushed (along with the un-flushed previous ones) only iffflushConnectionistrue.booleanSends a packet on this channel.booleansendAndFlush(Packet packet) Sends a packet on this channel and then blocks until it has been written to the connection.booleansendBatched(Packet packet) Sends a packet on this channel using batching algorithm if appropriatesendBlocking(Packet packet, byte expectedPacket) Sends a packet on this channel and then blocks until a response is received or a timeout occurs.sendBlocking(Packet packet, int reconnectID, byte expectedPacket) Sends a packet on this channel and then blocks until a response is received or a timeout occurs.sendBlocking(Packet packet, int reconnectID, byte expectedPacket, long timeout, boolean failOnTimeout) Due to networking issues or server issues the server may take longer to answer than expected.. the client may timeout the call throwing an exception and the client could eventually retry another call, but the server could then answer a previous command issuing a class-cast-exception.voidsets the handler to use when a confirmation is received.voidsetHandler(ChannelHandler handler) Sets theChannelHandlerthat this channel should forward received packets to.voidsetResponseHandler(ResponseHandler responseHandler) voidsetTransferring(boolean transferring) notifies the channel if it is transferring its connection.booleansupports(byte packetType) For protocol checkbooleansupports(byte packetType, int version) For protocol checktoString()voidtransferConnection(CoreRemotingConnection newConnection) Transfers the connection used by this channel to the one specified.voidunlock()unlocks the channel.
-
Constructor Details
-
ChannelImpl
public ChannelImpl(CoreRemotingConnection connection, long id, int confWindowSize, List<Interceptor> interceptors)
-
-
Method Details
-
getReconnectID
public int getReconnectID()Description copied from interface:ChannelThis number increases every time the channel reconnects successfully. This is used to guarantee the integrity of the channel on sequential commands such as large messages.- Specified by:
getReconnectIDin interfaceChannel
-
supports
public boolean supports(byte packetType) Description copied from interface:ChannelFor protocol check -
supports
public boolean supports(byte packetType, int version) Description copied from interface:ChannelFor protocol check -
requireSpecialVotingHandling
public boolean requireSpecialVotingHandling()- Specified by:
requireSpecialVotingHandlingin interfaceChannel
-
getID
public long getID()Description copied from interface:ChannelReturns the id of this channel. -
getLastConfirmedCommandID
public int getLastConfirmedCommandID()Description copied from interface:ChannelReturns the last confirmed packet command id.- Specified by:
getLastConfirmedCommandIDin interfaceChannel- Returns:
- the last confirmed packet command id
-
getLock
Description copied from interface:ChannelReturns the channel lock. -
getConfirmationWindowSize
public int getConfirmationWindowSize()Description copied from interface:ChannelReturns the confirmation window size this channel is using.- Specified by:
getConfirmationWindowSizein interfaceChannel- Returns:
- the confirmation window size this channel is using
-
returnBlocking
public void returnBlocking()Description copied from interface:Channelforces anyChannel.sendBlocking(Packet, byte)request to return with an exception.- Specified by:
returnBlockingin interfaceChannel
-
returnBlocking
Description copied from interface:Channelforces anyChannel.sendBlocking(Packet, byte)request to return with an exception.- Specified by:
returnBlockingin interfaceChannel
-
flushConnection
public void flushConnection()Description copied from interface:ChannelSimilarly toflushConnectiononChannel.send(Packet, boolean), it requests any un-flushed previous sent packets to be flushed to the underlying connection.It can be a no-op in case of InVM transports, because they would likely to flush already on each send.
- Specified by:
flushConnectionin interfaceChannel
-
send
Description copied from interface:ChannelSends a packet on this channel, but request it to be flushed (along with the un-flushed previous ones) only iffflushConnectionistrue.- Specified by:
sendin interfaceChannel- Parameters:
packet- the packet to sendflushConnection- iftruerequests thispacketand any un-flushed previous sent one to be flushed to the underlying connection- Returns:
- false if the packet was rejected by an outgoing interceptor;
trueif the send was successful
-
sendAndFlush
Description copied from interface:ChannelSends a packet on this channel and then blocks until it has been written to the connection.- Specified by:
sendAndFlushin interfaceChannel- Parameters:
packet- the packet to send- Returns:
- false if the packet was rejected by an outgoing interceptor;
trueif the send was successful
-
send
Description copied from interface:ChannelSends a packet on this channel. -
send
Description copied from interface:ChannelSends a packet on this channel. -
sendBatched
Description copied from interface:ChannelSends a packet on this channel using batching algorithm if appropriate- Specified by:
sendBatchedin interfaceChannel- Parameters:
packet- the packet to send- Returns:
- false if the packet was rejected by an outgoing interceptor;
trueif the send was successful
-
setTransferring
public void setTransferring(boolean transferring) Description copied from interface:Channelnotifies the channel if it is transferring its connection. Whentrueit is illegal to send messages.- Specified by:
setTransferringin interfaceChannel- Parameters:
transferring- whether the channel is transferring
-
getCache
-
sendBlocking
Description copied from interface:ChannelSends a packet on this channel and then blocks until a response is received or a timeout occurs.- Specified by:
sendBlockingin interfaceChannel- Parameters:
packet- the packet to sendexpectedPacket- the packet being expected.- Returns:
- the response
- Throws:
ActiveMQException- if an error occurs during the send
-
sendBlocking
public Packet sendBlocking(Packet packet, int reconnectID, byte expectedPacket) throws ActiveMQException Description copied from interface:ChannelSends a packet on this channel and then blocks until a response is received or a timeout occurs.- Specified by:
sendBlockingin interfaceChannel- Parameters:
packet- the packet to sendexpectedPacket- the packet being expected.- Returns:
- the response
- Throws:
ActiveMQException- if an error occurs during the send
-
sendBlocking
public Packet sendBlocking(Packet packet, int reconnectID, byte expectedPacket, long timeout, boolean failOnTimeout) throws ActiveMQException Due to networking issues or server issues the server may take longer to answer than expected.. the client may timeout the call throwing an exception and the client could eventually retry another call, but the server could then answer a previous command issuing a class-cast-exception. The expectedPacket will be used to filter out undesirable packets that would belong to previous calls.- Specified by:
sendBlockingin interfaceChannel- Throws:
ActiveMQException
-
invokeInterceptors
public static String invokeInterceptors(Packet packet, List<Interceptor> interceptors, RemotingConnection connection) Returns the name of the interceptor that returnedfalseornullif no interceptors returnedfalse.- Parameters:
packet- the packet to intercept- Returns:
- the name of the interceptor that returned
falseornullif no interceptors returnedfalse
-
setCommandConfirmationHandler
Description copied from interface:Channelsets the handler to use when a confirmation is received.- Specified by:
setCommandConfirmationHandlerin interfaceChannel- Parameters:
handler- the handler to call
-
setResponseHandler
- Specified by:
setResponseHandlerin interfaceChannel
-
setHandler
Description copied from interface:ChannelSets theChannelHandlerthat this channel should forward received packets to.- Specified by:
setHandlerin interfaceChannel- Parameters:
handler- the handler
-
getHandler
Description copied from interface:ChannelGets theChannelHandlerthat this channel should forward received packets to.- Specified by:
getHandlerin interfaceChannel- Returns:
- the current channel handler
-
endOfBatch
public void endOfBatch()- Specified by:
endOfBatchin interfaceChannel
-
close
public void close()Description copied from interface:ChannelCloses this channel.once closed no packets can be sent.
-
transferConnection
Description copied from interface:ChannelTransfers the connection used by this channel to the one specified.All new packets will be sent via this connection.
- Specified by:
transferConnectionin interfaceChannel- Parameters:
newConnection- the new connection
-
replayCommands
public void replayCommands(int otherLastConfirmedCommandID) Description copied from interface:Channelresends any packets that have not received confirmations yet.Typically called after a connection has been transferred.
- Specified by:
replayCommandsin interfaceChannel- Parameters:
otherLastConfirmedCommandID- the last confirmed packet
-
isLocked
public boolean isLocked()Description copied from interface:Channelqueries if this channel is locked. This method is designed for use in monitoring of the system state, not for synchronization control. -
lock
public void lock()Description copied from interface:Channellocks the channel.While locked no packets can be sent or received
-
unlock
public void unlock()Description copied from interface:Channelunlocks the channel. -
getConnection
Description copied from interface:ChannelReturns theCoreRemotingConnectionbeing used by the channel.- Specified by:
getConnectionin interfaceChannel- Returns:
- the
CoreRemotingConnectionbeing used by the channel
-
flushConfirmations
public void flushConfirmations()Description copied from interface:Channelflushes any confirmations on to the connection.- Specified by:
flushConfirmationsin interfaceChannel
-
handleAsyncResponse
-
confirm
Description copied from interface:Channelsends a confirmation of a packet being received. -
clearCommands
public void clearCommands()Description copied from interface:Channelclears any commands from the cache that are yet to be confirmed.- Specified by:
clearCommandsin interfaceChannel
-
handlePacket
Description copied from interface:ChannelCalled byCoreRemotingConnectionwhen a packet is received.This method should then call its
ChannelHandlerafter appropriate processing of the packet- Specified by:
handlePacketin interfaceChannel- Parameters:
packet- the packet to process.
-
toString
-