Class PersistentStreamConnection

java.lang.Object
org.axonframework.axonserver.connector.event.axon.PersistentStreamConnection

public class PersistentStreamConnection extends Object
A connection instance receiving the events for a persistent stream to pass on in batches of events to an event consumer.
Since:
4.10.0
Author:
Marc Gathier
  • Constructor Details

    • PersistentStreamConnection

      public PersistentStreamConnection(String streamId, Configuration configuration, io.axoniq.axonserver.connector.event.PersistentStreamProperties persistentStreamProperties, ScheduledExecutorService scheduler, int batchSize)
      Instantiates a connection for a persistent stream.
      Parameters:
      streamId - The unique identifier of the persistent stream.
      configuration - Global configuration of Axon components.
      persistentStreamProperties - Properties for the persistent stream.
      scheduler - Scheduler thread pool to schedule tasks.
      batchSize - The batch size for collecting events.
    • PersistentStreamConnection

      public PersistentStreamConnection(String streamId, Configuration configuration, io.axoniq.axonserver.connector.event.PersistentStreamProperties persistentStreamProperties, ScheduledExecutorService scheduler, int batchSize, String defaultContext)
      Instantiates a connection for a persistent stream.
      Parameters:
      streamId - The unique identifier of the persistent stream.
      configuration - Global configuration of Axon components.
      persistentStreamProperties - Properties for the persistent stream.
      scheduler - Scheduler thread pool to schedule tasks.
      batchSize - The batch size for collecting events.
      defaultContext - The default context to use for the connection.
  • Method Details

    • open

      public void open(Consumer<List<? extends EventMessage<?>>> consumer)
      Initiates the connection to Axon Server to read events from the persistent stream. The stream can be opened just once with a single consumer. The connection is exclusive to that consumer. If you try to open it again, an IllegalStateException is thrown.
      Parameters:
      consumer - The consumer of batches of event messages.
      Throws:
      IllegalStateException - if the stream was already opened.
    • close

      public void close()
      Closes the persistent stream connection to Axon Server.