Class CloseAwareReplyChannel<T>
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.CloseAwareReplyChannel<T>
-
- Type Parameters:
T- the type of messages flowing through thisReplyChannel
- All Implemented Interfaces:
ReplyChannel<T>
public class CloseAwareReplyChannel<T> extends Object implements ReplyChannel<T>
AReplyChannelimplementation that will trigger a givenactionwhen it is closed.- Since:
- 4.6.0
- Author:
- Milan Savic, Stefan Dragisic, Allard Buijze
-
-
Constructor Summary
Constructors Constructor Description CloseAwareReplyChannel(ReplyChannel<T> delegate)Instantiates thisReplyChannelwith givendelegate.CloseAwareReplyChannel(ReplyChannel<T> delegate, Runnable onClose)Instantiates thisReplyChannelwith givendelegateandonCloseRunnableexecution to be executed once the channel is closed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Marks the inbound instruction as completed.voidcompleteWithError(ErrorCategory errorCategory, String message)Marks the inbound instruction as exceptionally completed.voidcompleteWithError(ErrorMessage errorMessage)Marks the inbound instruction as exceptionally completed.booleanisClosed()Indicates whether thisReplyChannelis closed.voidsend(T outboundMessage)Sends the givenoutboundMessageas a reply to an incoming instruction.voidsendAck()Sends a receipt acknowledgement if one hasn't been sent yet for this instruction.voidsendLast(T outboundMessage)Sends the givenresponseand marks the processing as completed, possibly signalling flow control that more query messages may be sent.voidsendNack()Sends a negative acknowledgement, indicating that the incoming message could not be handled as expected.voidsendNack(ErrorMessage errorMessage)Sends a negative acknowledgement, indicating that the incoming message could not be handled as expected, using givenerrorMessageto describe the reason.
-
-
-
Constructor Detail
-
CloseAwareReplyChannel
public CloseAwareReplyChannel(ReplyChannel<T> delegate)
Instantiates thisReplyChannelwith givendelegate.- Parameters:
delegate- the delegate
-
CloseAwareReplyChannel
public CloseAwareReplyChannel(ReplyChannel<T> delegate, Runnable onClose)
Instantiates thisReplyChannelwith givendelegateandonCloseRunnableexecution to be executed once the channel is closed.- Parameters:
delegate- the delegateonClose- to be executed when channel is closed
-
-
Method Detail
-
send
public void send(T outboundMessage)
Description copied from interface:ReplyChannelSends the givenoutboundMessageas a reply to an incoming instruction. Where possible, the instruction identifiers should be set on the outbound message.- Specified by:
sendin interfaceReplyChannel<T>- Parameters:
outboundMessage- the message to send
-
sendLast
public void sendLast(T outboundMessage)
Description copied from interface:ReplyChannelSends the givenresponseand marks the processing as completed, possibly signalling flow control that more query messages may be sent.No more responses should be sent after invoking this method. The behavior in that case is undefined, and these messages are likely to be ignored.
- Specified by:
sendLastin interfaceReplyChannel<T>
-
sendAck
public void sendAck()
Description copied from interface:ReplyChannelSends a receipt acknowledgement if one hasn't been sent yet for this instruction. If the incoming instruction has no instruction ID, this method does nothing.- Specified by:
sendAckin interfaceReplyChannel<T>- See Also:
ReplyChannel.complete()
-
sendNack
public void sendNack()
Description copied from interface:ReplyChannelSends a negative acknowledgement, indicating that the incoming message could not be handled as expected. UnlikeReplyChannel.sendNack(ErrorMessage), no specific error details are provided. If the incoming instruction has no instruction ID, this method does nothing.- Specified by:
sendNackin interfaceReplyChannel<T>- See Also:
ReplyChannel.completeWithError(ErrorMessage),ReplyChannel.completeWithError(ErrorCategory, String)
-
sendNack
public void sendNack(ErrorMessage errorMessage)
Description copied from interface:ReplyChannelSends a negative acknowledgement, indicating that the incoming message could not be handled as expected, using givenerrorMessageto describe the reason. The givenerrorMessageshould provide sufficient information about the error. If the incoming instruction has no instruction ID, this method does nothing.- Specified by:
sendNackin interfaceReplyChannel<T>- See Also:
ReplyChannel.completeWithError(ErrorMessage),ReplyChannel.completeWithError(ErrorCategory, String)
-
complete
public void complete()
Description copied from interface:ReplyChannelMarks the inbound instruction as completed.- Specified by:
completein interfaceReplyChannel<T>
-
completeWithError
public void completeWithError(ErrorMessage errorMessage)
Description copied from interface:ReplyChannelMarks the inbound instruction as exceptionally completed. The givenerrorMessageshould provide sufficient information about the error.- Specified by:
completeWithErrorin interfaceReplyChannel<T>- Parameters:
errorMessage- the ErrorMessage describing the error
-
completeWithError
public void completeWithError(ErrorCategory errorCategory, String message)
Description copied from interface:ReplyChannelMarks the inbound instruction as exceptionally completed. The givenerrorCategoryandmessageshould provide sufficient information about the error.- Specified by:
completeWithErrorin interfaceReplyChannel<T>- Parameters:
errorCategory- the category that best described the error encounteredmessage- a message providing more details about the Error
-
isClosed
public boolean isClosed()
Indicates whether thisReplyChannelis closed.- Returns:
trueif closed,falseotherwise
-
-