Class PersistentStreamConnection
java.lang.Object
org.axonframework.axonserver.connector.event.axon.PersistentStreamConnection
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 Summary
ConstructorsConstructorDescriptionPersistentStreamConnection(String streamId, Configuration configuration, io.axoniq.axonserver.connector.event.PersistentStreamProperties persistentStreamProperties, ScheduledExecutorService scheduler, int batchSize) Instantiates a connection for a persistent stream.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. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the persistent stream connection to Axon Server.voidopen(Consumer<List<? extends EventMessage<?>>> consumer) Initiates the connection to Axon Server to read events from the persistent stream.
-
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
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, anIllegalStateExceptionis 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.
-