Interface DcbEventChannel

  • All Known Implementing Classes:
    DcbEventChannelImpl

    public interface DcbEventChannel
    Communication channel for Event related interaction with Axon Server based on the Dynamic Consistency Boundaries concept.
    Since:
    2025.1.0
    Author:
    Milan Savic
    • 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 a Collection of taggedEvents and returns the completableFuture which contains the AppendEventsResponse when 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 a Collection of taggedEvents with ConsistencyCondition and returns the completableFuture which contains the AppendEventsResponse when awaited.
        Parameters:
        taggedEvents - the collection of events to be appended
        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 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 of taggedEvents with ConsistencyCondition and returns the completableFuture which contains the AppendEventsResponse when awaited.
        Parameters:
        taggedEvents - the 1..n of events to be appended
        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 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 of taggedEvents and returns the completableFuture which contains the AppendEventsResponse when 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 given request and 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 given request and keeping a local buffer of bufferSize. 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 bufferSize smaller 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 events
        bufferSize - 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 given request and keeping a local buffer of bufferSize, which is refilled after consuming refillBatch events.

        A value for bufferSize smaller than 64 events will result in a buffer of 64. A value for refillBatch smaller than 16 will result in a refill batch of 16. A value larger than the bufferSize will be reduced to match the given bufferSize. While this will work, it is not recommended. The refillBatch should 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 events
        bufferSize - the number of events to buffer locally
        refillBatch - 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 event
        tags - 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 event
        tags - the tags to remove from the event
        Returns:
        a CompletableFuture containing the response
      • 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 given event to be published after given triggerDuration. 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 event
        event - the event to publish
        Returns:
        a token used to cancel the schedule
      • scheduleEvent

        CompletableFuture<String> scheduleEvent​(Instant scheduleTime,
                                                Event event)
        Schedule the given event to be published at given scheduleTime. 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 event
        event - 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 given scheduleToken was 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 given scheduleToken and reschedule it to be published after given triggerDuration. If no event is provided, the original event will be rescheduled.
        Parameters:
        scheduleToken - the token of the event to cancel
        triggerDuration - the point amount of time to wait to publish the event
        event - 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 given scheduleToken and reschedule it to be published at given scheduleTime. If no event is provided, the original event will be rescheduled.
        Parameters:
        scheduleToken - the token of the event to cancel
        scheduleTime - the point in time to publish the event
        event - an optional new event to publish
        Returns:
        a future reference to the token for the new schedule