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
|
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. |
boolean |
send(Packet packet)
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.
|
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
|
void |
transferConnection(CoreRemotingConnection newConnection)
Transfers the connection used by this channel to the one specified.
|
void |
unlock()
unlocks the channel.
|
long getID()
boolean supports(byte packetID)
boolean send(Packet packet)
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 HornetQException
packet
- the packet to sendexpectedPacket
- the packet being expected.HornetQException
- 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()
void transferConnection(CoreRemotingConnection newConnection)
newConnection
- the new connectionvoid replayCommands(int lastConfirmedCommandID)
lastConfirmedCommandID
- the last confirmed packetint getLastConfirmedCommandID()
void lock()
void unlock()
void returnBlocking()
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 packetpacket
- the packet to process.void clearCommands()
int getConfirmationWindowSize()
void setTransferring(boolean transferring)
transferring
- whether the channel is transferringCopyright © 2013 JBoss, a division of Red Hat. All rights reserved.