For the sake of simplicity the interface contains methods for sending and receiving of messages but each separate instance if ChannelHandler
is only required to perform either sending or receiving of messages depending on which side of a virtual channel it is handling.
It is guaranteed that for sending side the receiving methods will not be called and vice versa. In case there are separate implementations of ChannelHandler
for sending and receiving sides unimplemented methods should throw {@link UnsupportedOperationException}.
ChannelHandler
must act independently of other instances. That is: ChannelHandler
will be accessed by one thread at a time with the exception of stop()
method. It may (and usually will) be called concurrently by another thread. All non-constructor methods except stop()
will normally be accessed only by one thread throughout the lifetime of a ChannelHandler
instance. If the message has been successfully forwarded then {@link #commit}method is called signifying that the message has been successfully received and can be removed from transmission queue. If the message forwarding failed for some reason (communication, processing or other reason) {@link #rollback}method is called signifying that the message must be returned to the transmission queue and its delivery must be reattempted.
stop()
is called while the channel and respective ports are still operational. The second stage matches that of the sending endpoint. When close()
method is called the channel handler should release any resources allocated to this communication channel. If a transaction is still active during the closing of channel it must be rolled back automatically.
@author Baltic Amadeus, JSC
@author Antanas Kompanas
|
|