Class AbstractAxonServerChannel<OUT>
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel<OUT>
-
- Type Parameters:
OUT- generic defining the type of instructions a channel implementation can send
- Direct Known Subclasses:
AdminChannelImpl,CommandChannelImpl,ControlChannelImpl,DcbEventChannelImpl,EventChannelImpl,EventTransformationChannelImpl,QueryChannelImpl,SnapshotChannelImpl
public abstract class AbstractAxonServerChannel<OUT> extends Object
Abstract class representing a channel with AxonServer.- Author:
- Allard Buijze
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAxonServerChannel(ClientIdentification clientIdentification, ScheduledExecutorService executor, AxonServerManagedChannel axonServerManagedChannel)Instantiate anAbstractAxonServerChannel.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidconnect()Connect this channel with AxonServer.abstract voiddisconnect()Disconnect this channel from AxonServer.abstract booleanisReady()Validate whether this channel has all required streams connected with AxonServer.protected voidprocessAck(InstructionAck ack)Process the givenackby completing the instruction it refers to, if any can be found.abstract voidreconnect()Reconnect this channel with AxonServer.protected voidscheduleImmediateReconnect()Schedule an immediate attempt to reconnect with AxonServer.protected voidscheduleReconnect(Throwable disconnectReason)Schedule an attempt to reconnect with AxonServer.protected CompletableFuture<Void>sendInstruction(OUT instruction, Function<OUT,String> instructionIdProvider, io.grpc.stub.StreamObserver<OUT> outboundStream)Send the giveninstructionover the givenoutboundStream.
-
-
-
Constructor Detail
-
AbstractAxonServerChannel
protected AbstractAxonServerChannel(ClientIdentification clientIdentification, ScheduledExecutorService executor, AxonServerManagedChannel axonServerManagedChannel)
Instantiate anAbstractAxonServerChannel.- Parameters:
executor- aScheduledExecutorServiceused to schedule reconnectionsaxonServerManagedChannel- theAxonServerManagedChannelused to connect to AxonServer
-
-
Method Detail
-
sendInstruction
protected CompletableFuture<Void> sendInstruction(OUT instruction, Function<OUT,String> instructionIdProvider, io.grpc.stub.StreamObserver<OUT> outboundStream)
Send the giveninstructionover the givenoutboundStream. Will use the giveninstructionIdProviderto retrieve the instruction identifier to keep track when theinstructionhas been acknowledged.- Parameters:
instruction- the instruction of typeOUTto sendinstructionIdProvider- extraction function retrieving the instruction identifier from the giveninstructionoutboundStream-StreamObserverto send the giveninstructionover- Returns:
- a
CompletableFutureresolving successfully or exceptionally depending on the outcome of the dispatchedinstruction
-
processAck
protected void processAck(InstructionAck ack)
Process the givenackby completing the instruction it refers to, if any can be found.- Parameters:
ack- theInstructionAckreferring to an instruction which has been sent through thesendInstruction(Object, Function, StreamObserver)method
-
scheduleReconnect
protected void scheduleReconnect(Throwable disconnectReason)
Schedule an attempt to reconnect with AxonServer. Depending on thedisconnectReason, the reconnect attempt will be executed within 500ms or 5000ms.- Parameters:
disconnectReason- The reason why the previous connection failed.
-
scheduleImmediateReconnect
protected void scheduleImmediateReconnect()
Schedule an immediate attempt to reconnect with AxonServer.
-
connect
public abstract void connect()
Connect this channel with AxonServer.
-
reconnect
public abstract void reconnect()
Reconnect this channel with AxonServer.
-
disconnect
public abstract void disconnect()
Disconnect this channel from AxonServer.
-
isReady
public abstract boolean isReady()
Validate whether this channel has all required streams connected with AxonServer. If the state of the channel does not require any active streams, it is considered ready and will returntrue.- Returns:
trueif this channel is connected with AxonServer or does not require any active connections,falseotherwise
-
-