Class DcbEventChannelImpl

    • Method Detail

      • isReady

        public boolean isReady()
        Description copied from class: AbstractAxonServerChannel
        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 return true.
        Specified by:
        isReady in class AbstractAxonServerChannel<Void>
        Returns:
        true if this channel is connected with AxonServer or does not require any active connections, false otherwise
      • startTransaction

        public DcbEventChannel.AppendEventsTransaction startTransaction​(ConsistencyCondition condition)
        Description copied from interface: DcbEventChannel
        Starts a new transaction to conditionally append events.
        Specified by:
        startTransaction in interface DcbEventChannel
        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: DcbEventChannel
        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.

        Specified by:
        stream in interface DcbEventChannel
        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

        public ResultStream<SourceEventsResponse> source​(SourceEventsRequest request)
        Description copied from interface: DcbEventChannel
        Provides a finite stream of events used to eventsource a model.
        Specified by:
        source in interface DcbEventChannel
        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
      • append

        public CompletableFuture<AppendEventsResponse> append​(Collection<TaggedEvent> taggedEvents,
                                                              ConsistencyCondition condition)
        Description copied from interface: DcbEventChannel
        Appends a Collection of taggedEvents with ConsistencyCondition and returns the completableFuture which contains the AppendEventsResponse when awaited.
        Specified by:
        append in interface DcbEventChannel
        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.
      • getSequenceAt

        public CompletableFuture<GetSequenceAtResponse> getSequenceAt​(Instant timestamp)
        Description copied from interface: DcbEventChannel
        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.
        Specified by:
        getSequenceAt in interface DcbEventChannel
        Parameters:
        timestamp - the timestamp containing the timestamp to find the sequence for
        Returns:
        the sequence at the given timestamp
      • scheduleEvent

        public CompletableFuture<String> scheduleEvent​(Instant scheduleTime,
                                                       Event event)
        Description copied from interface: DcbEventChannel
        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.
        Specified by:
        scheduleEvent in interface DcbEventChannel
        Parameters:
        scheduleTime - The scheduleTime at which to publish the event
        event - The event to publish
        Returns:
        a token used to cancel the schedule
      • cancelSchedule

        public CompletableFuture<InstructionAck> cancelSchedule​(String token)
        Description copied from interface: DcbEventChannel
        Cancels the scheduled publication of an event for which the given scheduleToken was returned.
        Specified by:
        cancelSchedule in interface DcbEventChannel
        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: DcbEventChannel
        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.
        Specified by:
        reschedule in interface DcbEventChannel
        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