Class DcbEventChannelImpl
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel<Void>
-
- io.axoniq.axonserver.connector.event.impl.DcbEventChannelImpl
-
- All Implemented Interfaces:
DcbEventChannel
public class DcbEventChannelImpl extends AbstractAxonServerChannel<Void> implements DcbEventChannel
DcbEventChannelimplementation, serving as the event connection between Axon Server and a client application.- Since:
- 2025.1.0
- Author:
- Milan Savic
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.axoniq.axonserver.connector.event.DcbEventChannel
DcbEventChannel.AppendEventsTransaction
-
-
Constructor Summary
Constructors Constructor Description DcbEventChannelImpl(ClientIdentification clientIdentification, ScheduledExecutorService executor, AxonServerManagedChannel axonServerManagedChannel)Instantiate anAbstractAxonServerChannel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<AddTagsResponse>addTags(long sequence, Collection<Tag> tags)Assigns tags to the event identified by its sequence.CompletableFuture<AppendEventsResponse>append(Collection<TaggedEvent> taggedEvents, ConsistencyCondition condition)Appends aCollectionoftaggedEventswithConsistencyConditionand returns the completableFuture which contains theAppendEventsResponsewhen awaited.CompletableFuture<InstructionAck>cancelSchedule(String token)Cancels the scheduled publication of an event for which the givenscheduleTokenwas returned.voidconnect()Connect this channel with AxonServer.voiddisconnect()Disconnect this channel from AxonServer.CompletableFuture<GetSequenceAtResponse>getSequenceAt(Instant timestamp)Provides the sequence number of the event closest to the given timestamp.CompletableFuture<GetHeadResponse>head()Provides the head of the event store.booleanisReady()Validate whether this channel has all required streams connected with AxonServer.voidreconnect()Reconnect this channel with AxonServer.CompletableFuture<RemoveTagsResponse>removeTags(long sequence, Collection<Tag> tags)Removes tags from the event identified by its sequence.CompletableFuture<String>reschedule(String scheduleToken, Instant scheduleTime, Event event)Reschedules the scheduled event with the givenscheduleTokenand reschedule it to be published at givenscheduleTime.CompletableFuture<String>scheduleEvent(Instant scheduleTime, Event event)Schedule the giveneventto be published at givenscheduleTime.ResultStream<SourceEventsResponse>source(SourceEventsRequest request)Provides a finite stream of events used to eventsource a model.DcbEventChannel.AppendEventsTransactionstartTransaction()Starts a new transaction to unconditionally append events.DcbEventChannel.AppendEventsTransactionstartTransaction(ConsistencyCondition condition)Starts a new transaction to conditionally append events.ResultStream<StreamEventsResponse>stream(StreamEventsRequest request, int bufferSize, int refillBatch)Opens an infinite stream of events, for sequentially consuming events from Axon Server, using the givenrequestand keeping a local buffer ofbufferSize, which is refilled after consumingrefillBatchevents.CompletableFuture<GetTagsResponse>tagsFor(long sequence)Provides tags for an event at the given global sequence.CompletableFuture<GetTailResponse>tail()Provides the tail of the event store.-
Methods inherited from class io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel
processAck, scheduleImmediateReconnect, scheduleReconnect, sendInstruction
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.axoniq.axonserver.connector.event.DcbEventChannel
append, append, append, reschedule, scheduleEvent, stream, stream
-
-
-
-
Constructor Detail
-
DcbEventChannelImpl
public DcbEventChannelImpl(ClientIdentification clientIdentification, ScheduledExecutorService executor, AxonServerManagedChannel axonServerManagedChannel)
Instantiate anAbstractAxonServerChannel.- Parameters:
clientIdentification- the identification of the clientexecutor- aScheduledExecutorServiceused to schedule reconnectionsaxonServerManagedChannel- theAxonServerManagedChannelused to connect to AxonServer
-
-
Method Detail
-
connect
public void connect()
Description copied from class:AbstractAxonServerChannelConnect this channel with AxonServer.- Specified by:
connectin classAbstractAxonServerChannel<Void>
-
reconnect
public void reconnect()
Description copied from class:AbstractAxonServerChannelReconnect this channel with AxonServer.- Specified by:
reconnectin classAbstractAxonServerChannel<Void>
-
disconnect
public void disconnect()
Description copied from class:AbstractAxonServerChannelDisconnect this channel from AxonServer.- Specified by:
disconnectin classAbstractAxonServerChannel<Void>
-
isReady
public boolean isReady()
Description copied from class:AbstractAxonServerChannelValidate 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.- Specified by:
isReadyin classAbstractAxonServerChannel<Void>- Returns:
trueif this channel is connected with AxonServer or does not require any active connections,falseotherwise
-
startTransaction
public DcbEventChannel.AppendEventsTransaction startTransaction()
Description copied from interface:DcbEventChannelStarts a new transaction to unconditionally append events.- Specified by:
startTransactionin interfaceDcbEventChannel- Returns:
- the transaction reference onto which to register events to append
-
startTransaction
public DcbEventChannel.AppendEventsTransaction startTransaction(ConsistencyCondition condition)
Description copied from interface:DcbEventChannelStarts a new transaction to conditionally append events.- Specified by:
startTransactionin interfaceDcbEventChannel- Parameters:
condition- the Consistency Condition used to validate the Transaction. Axon Server will validate this condition against the Event Store and based on the validation outcome will accept or reject the transaction.- Returns:
- the transaction reference onto which to register events to append
-
stream
public ResultStream<StreamEventsResponse> stream(StreamEventsRequest request, int bufferSize, int refillBatch)
Description copied from interface:DcbEventChannelOpens an infinite stream of events, for sequentially consuming events from Axon Server, using the givenrequestand keeping a local buffer ofbufferSize, which is refilled after consumingrefillBatchevents.A value for
bufferSizesmaller than 64 events will result in a buffer of 64. A value forrefillBatchsmaller than 16 will result in a refill batch of 16. A value larger than thebufferSizewill be reduced to match the givenbufferSize. While this will work, it is not recommended. TherefillBatchshould be sufficiently small to allow for a constant flow of events to consume.The stream of events starts immediately upon the invocation of this method, making the first events available for consumption as soon as they have arrived from Axon Server.
- Specified by:
streamin interfaceDcbEventChannel- Parameters:
request- the request used to filter eventsbufferSize- the number of events to buffer locallyrefillBatch- the number of events to be consumed prior to refilling the buffer- Returns:
- an infinite stream of events
-
source
public ResultStream<SourceEventsResponse> source(SourceEventsRequest request)
Description copied from interface:DcbEventChannelProvides a finite stream of events used to eventsource a model.- Specified by:
sourcein interfaceDcbEventChannel- Parameters:
request- the query used to filter out events for sourcing- Returns:
- the response containing events to source a model and a consistency marker to be used when trying to append new events to the event store
-
tagsFor
public CompletableFuture<GetTagsResponse> tagsFor(long sequence)
Description copied from interface:DcbEventChannelProvides tags for an event at the given global sequence.- Specified by:
tagsForin interfaceDcbEventChannel- Parameters:
sequence- the sequence of an event- Returns:
- the tags fo the event
-
append
public CompletableFuture<AppendEventsResponse> append(Collection<TaggedEvent> taggedEvents, ConsistencyCondition condition)
Description copied from interface:DcbEventChannelAppends aCollectionoftaggedEventswithConsistencyConditionand returns the completableFuture which contains theAppendEventsResponsewhen awaited.- Specified by:
appendin interfaceDcbEventChannel- Parameters:
taggedEvents- the collection of events to be appendedcondition- the Consistency Condition used to validate the Transaction. Axon Server will validate this condition against the Event Store and based on the validation outcome will accept or reject the transaction.- Returns:
- the future that completes once the Axon Server commits this Transaction, containing the append events response as a result.
-
head
public CompletableFuture<GetHeadResponse> head()
Description copied from interface:DcbEventChannelProvides the head of the event store.- Specified by:
headin interfaceDcbEventChannel- Returns:
- the head of the event store
-
tail
public CompletableFuture<GetTailResponse> tail()
Description copied from interface:DcbEventChannelProvides the tail of the event store.- Specified by:
tailin interfaceDcbEventChannel- Returns:
- the tail of the event store
-
getSequenceAt
public CompletableFuture<GetSequenceAtResponse> getSequenceAt(Instant timestamp)
Description copied from interface:DcbEventChannelProvides the sequence number of the event closest to the given timestamp. If the timestamp is before the first event, returns the tail sequence. If the timestamp is after the last event, returns the head sequence.- Specified by:
getSequenceAtin interfaceDcbEventChannel- Parameters:
timestamp- the timestamp containing the timestamp to find the sequence for- Returns:
- the sequence at the given timestamp
-
addTags
public CompletableFuture<AddTagsResponse> addTags(long sequence, Collection<Tag> tags)
Description copied from interface:DcbEventChannelAssigns tags to the event identified by its sequence.- Specified by:
addTagsin interfaceDcbEventChannel- Parameters:
sequence- the sequence of an eventtags- the tags to add to the event- Returns:
- a CompletableFuture containing the response
-
removeTags
public CompletableFuture<RemoveTagsResponse> removeTags(long sequence, Collection<Tag> tags)
Description copied from interface:DcbEventChannelRemoves tags from the event identified by its sequence.- Specified by:
removeTagsin interfaceDcbEventChannel- Parameters:
sequence- the sequence of an eventtags- the tags to remove from the event- Returns:
- a CompletableFuture containing the response
-
scheduleEvent
public CompletableFuture<String> scheduleEvent(Instant scheduleTime, Event event)
Description copied from interface:DcbEventChannelSchedule the giveneventto be published at givenscheduleTime. The returned value can be used to cancel the schedule, or to reschedule the event to another time.- Specified by:
scheduleEventin interfaceDcbEventChannel- Parameters:
scheduleTime- The scheduleTime at which to publish the eventevent- The event to publish- Returns:
- a token used to cancel the schedule
-
cancelSchedule
public CompletableFuture<InstructionAck> cancelSchedule(String token)
Description copied from interface:DcbEventChannelCancels the scheduled publication of an event for which the givenscheduleTokenwas returned.- Specified by:
cancelSchedulein interfaceDcbEventChannel- Parameters:
token- the token provided when scheduling the event to be cancelled- Returns:
- a future reference to the result of the instruction
-
reschedule
public CompletableFuture<String> reschedule(String scheduleToken, Instant scheduleTime, @Nullable Event event)
Description copied from interface:DcbEventChannelReschedules the scheduled event with the givenscheduleTokenand reschedule it to be published at givenscheduleTime. If no event is provided, the original event will be rescheduled.- Specified by:
reschedulein interfaceDcbEventChannel- Parameters:
scheduleToken- the token of the event to cancelscheduleTime- the point in time to publish the eventevent- an optional new event to publish- Returns:
- a future reference to the token for the new schedule
-
-