Class CloseAwareReplyChannel<T>

  • Type Parameters:
    T - the type of messages flowing through this ReplyChannel
    All Implemented Interfaces:
    ReplyChannel<T>

    public class CloseAwareReplyChannel<T>
    extends Object
    implements ReplyChannel<T>
    A ReplyChannel implementation that will trigger a given action when it is closed.
    Since:
    4.6.0
    Author:
    Milan Savic, Stefan Dragisic, Allard Buijze
    • Constructor Detail

      • CloseAwareReplyChannel

        public CloseAwareReplyChannel​(ReplyChannel<T> delegate)
        Instantiates this ReplyChannel with given delegate.
        Parameters:
        delegate - the delegate
      • CloseAwareReplyChannel

        public CloseAwareReplyChannel​(ReplyChannel<T> delegate,
                                      Runnable onClose)
        Instantiates this ReplyChannel with given delegate and onClose Runnable execution to be executed once the channel is closed.
        Parameters:
        delegate - the delegate
        onClose - to be executed when channel is closed
    • Method Detail

      • send

        public void send​(T outboundMessage)
        Description copied from interface: ReplyChannel
        Sends the given outboundMessage as a reply to an incoming instruction. Where possible, the instruction identifiers should be set on the outbound message.
        Specified by:
        send in interface ReplyChannel<T>
        Parameters:
        outboundMessage - the message to send
      • sendLast

        public void sendLast​(T outboundMessage)
        Description copied from interface: ReplyChannel
        Sends the given response and 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:
        sendLast in interface ReplyChannel<T>
      • sendAck

        public void sendAck()
        Description copied from interface: ReplyChannel
        Sends 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:
        sendAck in interface ReplyChannel<T>
        See Also:
        ReplyChannel.complete()
      • complete

        public void complete()
        Description copied from interface: ReplyChannel
        Marks the inbound instruction as completed.
        Specified by:
        complete in interface ReplyChannel<T>
      • completeWithError

        public void completeWithError​(ErrorMessage errorMessage)
        Description copied from interface: ReplyChannel
        Marks the inbound instruction as exceptionally completed. The given errorMessage should provide sufficient information about the error.
        Specified by:
        completeWithError in interface ReplyChannel<T>
        Parameters:
        errorMessage - the ErrorMessage describing the error
      • completeWithError

        public void completeWithError​(ErrorCategory errorCategory,
                                      String message)
        Description copied from interface: ReplyChannel
        Marks the inbound instruction as exceptionally completed. The given errorCategory and message should provide sufficient information about the error.
        Specified by:
        completeWithError in interface ReplyChannel<T>
        Parameters:
        errorCategory - the category that best described the error encountered
        message - a message providing more details about the Error
      • isClosed

        public boolean isClosed()
        Indicates whether this ReplyChannel is closed.
        Returns:
        true if closed, false otherwise