public interface Channel
CoreRemotingConnection
.
Any packet sent will have its channel id set to the specific channel sending so it can be routed to its correct channel
when received by the CoreRemotingConnection
. see Packet.setChannelID(long)
.
Each Channel should will forward any packets received to its ChannelHandler
.
A Channel *does not* support concurrent access by more than one thread!
Modifier and Type | Method and Description |
---|---|
void |
clearCommands()
clears any commands from the cache that are yet to be confirmed.
|
void |
close()
Closes this channel.
|
void |
confirm(Packet packet)
sends a confirmation of a packet being received.
|
void |
flushConfirmations()
flushes any confirmations on to the connection.
|
int |
getConfirmationWindowSize()
returns the confirmation window size this channel is using.
|
CoreRemotingConnection |
getConnection()
returns the
CoreRemotingConnection being used by the channel |
ChannelHandler |
getHandler()
Gets the
ChannelHandler that this channel should
forward received packets to. |
long |
getID()
Returns the id of this channel.
|
int |
getLastConfirmedCommandID()
returns the last confirmed packet command id
|
Lock |
getLock()
returns the channel lock
|
int |
getReconnectID()
This number increases every time the channel reconnects successfully.
|
void |
handlePacket(Packet packet)
Called by
CoreRemotingConnection when a packet is received. |
void |
lock()
locks the channel.
|
void |
replayCommands(int lastConfirmedCommandID)
resends any packets that have not received confirmations yet.
|
void |
returnBlocking()
forces any
sendBlocking(Packet, byte) request to return with an exception. |
void |
returnBlocking(Throwable cause)
forces any
sendBlocking(Packet, byte) request to return with an exception. |
boolean |
send(Packet packet)
Sends a packet on this channel.
|
boolean |
send(Packet packet,
int reconnectID)
Sends a packet on this channel.
|
boolean |
sendAndFlush(Packet packet)
Sends a packet on this channel and then blocks until it has been written to the connection.
|
boolean |
sendBatched(Packet packet)
Sends a packet on this channel using batching algorithm if appropriate
|
Packet |
sendBlocking(Packet packet,
byte expectedPacket)
Sends a packet on this channel and then blocks until a response is received or a timeout
occurs.
|
Packet |
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.
|
void |
setCommandConfirmationHandler(CommandConfirmationHandler handler)
sets the handler to use when a confirmation is received.
|
void |
setHandler(ChannelHandler handler)
Sets the
ChannelHandler that this channel should
forward received packets to. |
void |
setTransferring(boolean transferring)
notifies the channel if it is transferring its connection.
|
boolean |
supports(byte packetID)
For protocol check
|
boolean |
supports(byte packetID,
int version)
For protocol check
|
void |
transferConnection(CoreRemotingConnection newConnection)
Transfers the connection used by this channel to the one specified.
|
void |
unlock()
unlocks the channel.
|
long getID()
int getReconnectID()
boolean supports(byte packetID)
boolean supports(byte packetID, int version)
boolean send(Packet packet)
packet
- the packet to sendboolean send(Packet packet, int reconnectID)
packet
- the packet to sendboolean sendBatched(Packet packet)
packet
- the packet to sendboolean sendAndFlush(Packet packet)
packet
- the packet to sendPacket sendBlocking(Packet packet, byte expectedPacket) throws ActiveMQException
packet
- the packet to sendexpectedPacket
- the packet being expected.ActiveMQException
- if an error occurs during the sendPacket sendBlocking(Packet packet, int reconnectID, byte expectedPacket) throws ActiveMQException
packet
- the packet to sendexpectedPacket
- the packet being expected.ActiveMQException
- if an error occurs during the sendvoid setHandler(ChannelHandler handler)
ChannelHandler
that this channel should
forward received packets to.handler
- the handlerChannelHandler getHandler()
ChannelHandler
that this channel should
forward received packets to.void close()
once closed no packets can be sent.
void transferConnection(CoreRemotingConnection newConnection)
All new packets will be sent via this connection.
newConnection
- the new connectionvoid replayCommands(int lastConfirmedCommandID)
Typically called after a connection has been transferred.
lastConfirmedCommandID
- the last confirmed packetint getLastConfirmedCommandID()
void lock()
While locked no packets can be sent or received
void unlock()
void returnBlocking()
sendBlocking(Packet, byte)
request to return with an exception.void returnBlocking(Throwable cause)
sendBlocking(Packet, byte)
request to return with an exception.Lock getLock()
CoreRemotingConnection getConnection()
CoreRemotingConnection
being used by the channelvoid confirm(Packet packet)
packet
- the packet to confirmvoid setCommandConfirmationHandler(CommandConfirmationHandler handler)
handler
- the handler to callvoid flushConfirmations()
void handlePacket(Packet packet)
CoreRemotingConnection
when a packet is received.
This method should then call its ChannelHandler
after appropriate processing of
the packet
packet
- the packet to process.void clearCommands()
int getConfirmationWindowSize()
void setTransferring(boolean transferring)
transferring
- whether the channel is transferringCopyright © 2018 JBoss by Red Hat. All rights reserved.