Class PersistentStreamEventSource
java.lang.Object
io.axoniq.framework.axonserver.connector.event.PersistentStreamEventSource
- All Implemented Interfaces:
SubscribableEventSource
A
SubscribableEventSource that receives events from a persistent stream on Axon Server.
The persistent stream is identified by a unique name, which acts as the stream identifier in Axon Server.
Using the same name for different instances will join the same server-side stream. Each instance owns an exclusive
PersistentStreamConnection and may have at most one active subscriber at a time.
- Since:
- 5.2.0
- Author:
- Marc Gathier, Jakob Hatzl
-
Constructor Summary
ConstructorsConstructorDescriptionPersistentStreamEventSource(String name, AxonServerConnectionManager connectionManager, AxonServerConfiguration serverConfig, EventConverter converter, EventTypeResolver eventTypeResolver, io.axoniq.axonserver.connector.event.PersistentStreamProperties persistentStreamProperties, ScheduledExecutorService scheduler, UnitOfWorkFactory unitOfWorkFactory, int batchSize) Instantiates aPersistentStreamEventSource.PersistentStreamEventSource(String name, AxonServerConnectionManager connectionManager, AxonServerConfiguration serverConfig, EventConverter converter, EventTypeResolver eventTypeResolver, io.axoniq.axonserver.connector.event.PersistentStreamProperties persistentStreamProperties, ScheduledExecutorService scheduler, UnitOfWorkFactory unitOfWorkFactory, int batchSize, @Nullable String context) Instantiates aPersistentStreamEventSource. -
Method Summary
Modifier and TypeMethodDescriptionsubscribe(BiFunction<List<? extends EventMessage>, ProcessingContext, CompletableFuture<?>> eventsBatchConsumer) Subscribe the giveneventsBatchConsumerto this event source.
-
Constructor Details
-
PersistentStreamEventSource
public PersistentStreamEventSource(String name, AxonServerConnectionManager connectionManager, AxonServerConfiguration serverConfig, EventConverter converter, EventTypeResolver eventTypeResolver, io.axoniq.axonserver.connector.event.PersistentStreamProperties persistentStreamProperties, ScheduledExecutorService scheduler, UnitOfWorkFactory unitOfWorkFactory, int batchSize) Instantiates aPersistentStreamEventSource.- Parameters:
name- the name of the persistent stream; acts as the unique stream identifier in Axon ServerconnectionManager- the Axon Server connection managerserverConfig- the Axon Server configurationconverter- the event converter used to deserialize event payloadseventTypeResolver- the event type resolver used to resolve the type on inbound eventspersistentStreamProperties- the properties for the persistent streamscheduler- the scheduler thread pool to schedule tasksunitOfWorkFactory- theUnitOfWorkFactoryused to create a unit of work to span message processingbatchSize- the maximum number of events to collect per batch
-
PersistentStreamEventSource
public PersistentStreamEventSource(String name, AxonServerConnectionManager connectionManager, AxonServerConfiguration serverConfig, EventConverter converter, EventTypeResolver eventTypeResolver, io.axoniq.axonserver.connector.event.PersistentStreamProperties persistentStreamProperties, ScheduledExecutorService scheduler, UnitOfWorkFactory unitOfWorkFactory, int batchSize, @Nullable String context) Instantiates aPersistentStreamEventSource.- Parameters:
name- the name of the persistent stream; acts as the unique stream identifier in Axon ServerconnectionManager- the Axon Server connection managerserverConfig- the Axon Server configurationconverter- the event converter used to deserialize event payloadseventTypeResolver- the event type resolver used to resolve the type on inbound eventspersistentStreamProperties- the properties for the persistent streamscheduler- the scheduler thread pool to schedule tasksunitOfWorkFactory- theUnitOfWorkFactoryused to create a unit of work to span message processingbatchSize- the maximum number of events to collect per batchcontext- the Axon Server context in which this stream exists, ornullto use the context fromAxonServerConfiguration.getContext()
-
-
Method Details
-
subscribe
public Registration subscribe(BiFunction<List<? extends EventMessage>, ProcessingContext, CompletableFuture<?>> eventsBatchConsumer) Description copied from interface:SubscribableEventSourceSubscribe the giveneventsBatchConsumerto this event source. When subscribed, it will receive all events published to this source since the subscription.If the given
eventsBatchConsumeris already subscribed, nothing happens.Note on
ProcessingContext: TheProcessingContextparameter passed to the consumer may benull. Whennull, it is the responsibility of the registeredeventsBatchConsumerto create an appropriateProcessingContextas needed for processing the events.- Specified by:
subscribein interfaceSubscribableEventSource- Parameters:
eventsBatchConsumer- The event batches consumer to subscribe.- Returns:
- A
Registrationhandle to unsubscribe theeventsBatchConsumer. When unsubscribed, it will no longer receive events.
-