Class AbstractIncomingInstructionStream<IN,​OUT>

  • Type Parameters:
    IN - the type of instructions received by this stream
    OUT - the type of instructions returned by this stream
    All Implemented Interfaces:
    io.grpc.stub.ClientResponseObserver<OUT,​IN>, io.grpc.stub.StreamObserver<IN>

    public abstract class AbstractIncomingInstructionStream<IN,​OUT>
    extends FlowControlledStream<IN,​OUT>
    Abstract implementation of a FlowControlledStream for incoming message from AxonServer.
    Since:
    4.4
    Author:
    Allard Buijze
    • Constructor Detail

      • AbstractIncomingInstructionStream

        protected AbstractIncomingInstructionStream​(String clientId,
                                                    int permits,
                                                    int permitsBatch,
                                                    Consumer<Throwable> disconnectHandler,
                                                    Consumer<io.grpc.stub.CallStreamObserver<OUT>> beforeStartHandler)
        Parameters:
        clientId - the client identifier whom initiated this instruction stream
        permits - the number of permits this stream should receive
        permitsBatch - the number of permits to be consumed prior to requesting new permits
        disconnectHandler - a Consumer of Throwable invoked when this stream errors out
        beforeStartHandler - the handler to invoke when the upstream connection is available. Note that the gRPC call has not started yet at this point.
    • Method Detail

      • onNext

        public void onNext​(IN value)
      • buildAckMessage

        protected abstract OUT buildAckMessage​(InstructionAck ack)
        Builds a stream specific acknowledgment message of type OUT based on the given ack.
        Parameters:
        ack - the InstructionAck to base the stream specific acknowledgement on
        Returns:
        a stream specific acknowledgment message of type OUT based on the given ack
      • buildResultMessage

        protected Optional<OUT> buildResultMessage​(InstructionResult result)
        Builds a stream specific result message of type OUT based on the given result. If the Optional is empty, no instruction result will be sent. By default, this method returns an empty Optional. If the concrete class supports the InstructionResult it should override this method.
        Parameters:
        result - the InstructionResult to base the stream specific acknowledgement on
        Returns:
        a stream specific acknowledgment message of type OUT based on the given result
      • getInstructionId

        protected abstract String getInstructionId​(IN instruction)
        Returns the instruction identifier of the given instruction.
        Parameters:
        instruction - the instruction of type IN to retrieve the instruction identifier from
        Returns:
        the instruction identifier of the given instruction
      • onCompleted

        public void onCompleted()
      • onError

        public void onError​(Throwable t)
      • beforeStart

        public void beforeStart​(io.grpc.stub.ClientCallStreamObserver<OUT> requestStream)
        Specified by:
        beforeStart in interface io.grpc.stub.ClientResponseObserver<IN,​OUT>
        Overrides:
        beforeStart in class FlowControlledStream<IN,​OUT>
      • getInstructionsForPlatform

        public io.grpc.stub.ClientCallStreamObserver<OUT> getInstructionsForPlatform()
        Return the StreamObserver of type OUT serving as the outbound instruction channel.
        Returns:
        the StreamObserver of type OUT serving as the outbound instruction channel
      • unregisterOutboundStream

        protected abstract boolean unregisterOutboundStream​(io.grpc.stub.CallStreamObserver<OUT> expected)
        Deregisters this stream's outbound stream, granted that it matches the given expected StreamObserver. Will return true if they matched and false otherwise.
        Parameters:
        expected - the expected StreamObserver to be deregistered
        Returns:
        true if the outbound stream was successfully deregistered, false otherwise