Interface DcbEventChannel
-
- All Known Implementing Classes:
DcbEventChannelImpl
public interface DcbEventChannelCommunication channel for Event related interaction with Axon Server based on the Dynamic Consistency Boundaries concept.- Since:
- 2025.1.0
- Author:
- Milan Savic
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceDcbEventChannel.AppendEventsTransactionProvides operations to interact with a Transaction to append events and a condition onto the Event Store.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CompletableFuture<AddTagsResponse>addTags(long sequence, Collection<Tag> tags)Assigns tags to the event identified by its sequence.default CompletableFuture<AppendEventsResponse>append(ConsistencyCondition condition, TaggedEvent... taggedEvents)Appends variable number oftaggedEventswithConsistencyConditionand returns the completableFuture which contains theAppendEventsResponsewhen awaited.default CompletableFuture<AppendEventsResponse>append(TaggedEvent... taggedEvents)Appends variable number oftaggedEventsand returns the completableFuture which contains theAppendEventsResponsewhen awaited.default CompletableFuture<AppendEventsResponse>append(Collection<TaggedEvent> taggedEvents)Appends aCollectionoftaggedEventsand returns the completableFuture which contains theAppendEventsResponsewhen awaited.default CompletableFuture<AppendEventsResponse>append(Collection<TaggedEvent> taggedEvents, ConsistencyCondition condition)Appends aCollectionoftaggedEventswithConsistencyConditionand returns the completableFuture which contains theAppendEventsResponsewhen awaited.CompletableFuture<InstructionAck>cancelSchedule(String scheduleToken)Cancels the scheduled publication of an event for which the givenscheduleTokenwas returned.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.CompletableFuture<RemoveTagsResponse>removeTags(long sequence, Collection<Tag> tags)Removes tags from the event identified by its sequence.default CompletableFuture<String>reschedule(String scheduleToken, Duration triggerDuration, Event event)Reschedules the scheduled event with the givenscheduleTokenand reschedule it to be published after giventriggerDuration.CompletableFuture<String>reschedule(String scheduleToken, Instant scheduleTime, Event event)Reschedules the scheduled event with the givenscheduleTokenand reschedule it to be published at givenscheduleTime.default CompletableFuture<String>scheduleEvent(Duration triggerDuration, Event event)Schedule the giveneventto be published after giventriggerDuration.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.default ResultStream<StreamEventsResponse>stream(StreamEventsRequest request)Opens an infinite stream of events, for sequentially consuming events from Axon Server, using the givenrequestand keeping a local buffer of 64 events.default ResultStream<StreamEventsResponse>stream(StreamEventsRequest request, int bufferSize)Opens an infinite stream of events, for sequentially consuming events from Axon Server, using the givenrequestand keeping a local buffer ofbufferSize.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.
-
-
-
Method Detail
-
startTransaction
DcbEventChannel.AppendEventsTransaction startTransaction()
Starts a new transaction to unconditionally append events.- Returns:
- the transaction reference onto which to register events to append
-
startTransaction
DcbEventChannel.AppendEventsTransaction startTransaction(ConsistencyCondition condition)
Starts a new transaction to conditionally append events.- 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
-
append
default CompletableFuture<AppendEventsResponse> append(Collection<TaggedEvent> taggedEvents)
Appends aCollectionoftaggedEventsand returns the completableFuture which contains theAppendEventsResponsewhen awaited.- Parameters:
taggedEvents- the collection of events to be appended- Returns:
- the future that completes once the Axon Server commits this Transaction, containing the append events response as a result.
-
append
default CompletableFuture<AppendEventsResponse> append(Collection<TaggedEvent> taggedEvents, ConsistencyCondition condition)
Appends aCollectionoftaggedEventswithConsistencyConditionand returns the completableFuture which contains theAppendEventsResponsewhen awaited.- 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.
-
append
default CompletableFuture<AppendEventsResponse> append(ConsistencyCondition condition, TaggedEvent... taggedEvents)
Appends variable number oftaggedEventswithConsistencyConditionand returns the completableFuture which contains theAppendEventsResponsewhen awaited.- Parameters:
taggedEvents- the 1..n 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.
-
append
default CompletableFuture<AppendEventsResponse> append(TaggedEvent... taggedEvents)
Appends variable number oftaggedEventsand returns the completableFuture which contains theAppendEventsResponsewhen awaited.- Parameters:
taggedEvents- the 1..n of events to be appended- Returns:
- the future that completes once the Axon Server commits this Transaction, containing the append events response as a result.
-
stream
default ResultStream<StreamEventsResponse> stream(StreamEventsRequest request)
Opens an infinite stream of events, for sequentially consuming events from Axon Server, using the givenrequestand keeping a local buffer of 64 events. When consuming 16 events, the client will request additional events to keep the buffer filled.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.
- Parameters:
request- the request used to filter events- Returns:
- an infinite stream of events
- See Also:
to configure the buffer size
-
stream
default ResultStream<StreamEventsResponse> stream(StreamEventsRequest request, int bufferSize)
Opens an infinite stream of events, for sequentially consuming events from Axon Server, using the givenrequestand keeping a local buffer ofbufferSize. When consuming 1/8th of the buffer size (with a minimum of 16), the client will request additional events to keep the buffer filled.A value for
bufferSizesmaller than 64 events will result in a buffer of 64.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.
- Parameters:
request- the request used to filter eventsbufferSize- the number of events to buffer locally- Returns:
- an infinite stream of events
- See Also:
to configure the refill frequency
-
stream
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.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.
- 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
ResultStream<SourceEventsResponse> source(SourceEventsRequest request)
Provides a finite stream of events used to eventsource a model.- 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
CompletableFuture<GetTagsResponse> tagsFor(long sequence)
Provides tags for an event at the given global sequence.- Parameters:
sequence- the sequence of an event- Returns:
- the tags fo the event
-
addTags
CompletableFuture<AddTagsResponse> addTags(long sequence, Collection<Tag> tags)
Assigns tags to the event identified by its sequence.- Parameters:
sequence- the sequence of an eventtags- the tags to add to the event- Returns:
- a CompletableFuture containing the response
-
removeTags
CompletableFuture<RemoveTagsResponse> removeTags(long sequence, Collection<Tag> tags)
Removes tags from the event identified by its sequence.- Parameters:
sequence- the sequence of an eventtags- the tags to remove from the event- Returns:
- a CompletableFuture containing the response
-
head
CompletableFuture<GetHeadResponse> head()
Provides the head of the event store.- Returns:
- the head of the event store
-
tail
CompletableFuture<GetTailResponse> tail()
Provides the tail of the event store.- Returns:
- the tail of the event store
-
getSequenceAt
CompletableFuture<GetSequenceAtResponse> getSequenceAt(Instant timestamp)
Provides 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.- Parameters:
timestamp- the timestamp containing the timestamp to find the sequence for- Returns:
- the sequence at the given timestamp
-
scheduleEvent
default CompletableFuture<String> scheduleEvent(Duration triggerDuration, Event event)
Schedule the giveneventto be published after giventriggerDuration. The returned value can be used to cancel the schedule, or to reschedule the event to another time.- Parameters:
triggerDuration- the amount of time to wait to publish the eventevent- the event to publish- Returns:
- a token used to cancel the schedule
-
scheduleEvent
CompletableFuture<String> scheduleEvent(Instant scheduleTime, Event event)
Schedule the giveneventto be published at givenscheduleTime. The returned value can be used to cancel the schedule, or to reschedule the event to another time.- Parameters:
scheduleTime- The scheduleTime at which to publish the eventevent- The event to publish- Returns:
- a token used to cancel the schedule
-
cancelSchedule
CompletableFuture<InstructionAck> cancelSchedule(String scheduleToken)
Cancels the scheduled publication of an event for which the givenscheduleTokenwas returned.- Parameters:
scheduleToken- the token provided when scheduling the event to be cancelled- Returns:
- a future reference to the result of the instruction
-
reschedule
default CompletableFuture<String> reschedule(String scheduleToken, Duration triggerDuration, Event event)
Reschedules the scheduled event with the givenscheduleTokenand reschedule it to be published after giventriggerDuration. If no event is provided, the original event will be rescheduled.- Parameters:
scheduleToken- the token of the event to canceltriggerDuration- the point amount of time to wait to publish the eventevent- an optional new event to publish- Returns:
- a future reference to the token for the new schedule
-
reschedule
CompletableFuture<String> reschedule(String scheduleToken, Instant scheduleTime, @Nullable Event event)
Reschedules the scheduled event with the givenscheduleTokenand reschedule it to be published at givenscheduleTime. If no event is provided, the original event will be rescheduled.- 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
-
-