Class MultiTenantPersistentStreamEventSourceFactory
- All Implemented Interfaces:
PersistentStreamEventSourceFactory
PersistentStreamEventSourceFactory building a MultiTenantPersistentStreamEventSource, so a
configured persistent stream is consumed from every tenant's Axon Server context rather than from one.
Replaces the default factory while multi-tenancy is active, which is all a Spring Boot application needs to make its
persistent-stream-backed event processors multi-tenant: streams stay configured under
axon.axonserver.persistent-streams exactly as they are without multi-tenancy.
Marked Internal as concrete, internal implementation of the PersistentStreamEventSourceFactory.
- Since:
- 5.3.0
- Author:
- Jakob Hatzl
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(String name, io.axoniq.axonserver.connector.event.PersistentStreamProperties properties, ScheduledExecutorService scheduler, int batchSize, Configuration configuration) Always throws, since a singleScheduledExecutorServiceshared across every tenant would defeat the per-tenant thread isolation this factory exists to provide.build(String name, io.axoniq.axonserver.connector.event.PersistentStreamProperties properties, Function<String, ScheduledExecutorService> schedulerFactory, int batchSize, Configuration configuration) Builds theSubscribableEventSourceconsuming the persistent stream described by the given parameters, taking theScheduledExecutorServiceinstances it needs from the givenschedulerFactory.
-
Constructor Details
-
MultiTenantPersistentStreamEventSourceFactory
public MultiTenantPersistentStreamEventSourceFactory()
-
-
Method Details
-
build
public SubscribableEventSource build(String name, io.axoniq.axonserver.connector.event.PersistentStreamProperties properties, Function<String, ScheduledExecutorService> schedulerFactory, int batchSize, Configuration configuration) Builds theSubscribableEventSourceconsuming the persistent stream described by the given parameters, taking theScheduledExecutorServiceinstances it needs from the givenschedulerFactory.The supplied
Configurationprovides access to all registered framework components, such as theAxonServerConnectionManagerandEventConverter, so implementations do not need to receive those as constructor arguments.A factory is handed a scheduler factory rather than a scheduler, so implementations can create pools under their control. The requested pool name is used to name the pool's threads, so the source a thread belongs to is visible in a thread dump; pass the stream name for a single stream and a name distinguishing them for several.
For the
MultiTenantPersistentStreamEventSourceFactoryeach tenant's stream gets aScheduledExecutorServiceof its own, taken from the scheduler factory the contract supplies, so the configuredthread-countkeeps meaning "threads for this stream" and a tenant whose stream is retrying cannot occupy the threads the other tenants need. Pools are named after the stream and the tenant they belong to, so a thread dump shows whose stream a thread is working on.- Specified by:
buildin interfacePersistentStreamEventSourceFactory- Parameters:
name- the unique stream name on Axon Serverproperties- the persistent stream properties (segment count, sequencing policy, filter, etc.)schedulerFactory- the factory creating aScheduledExecutorServicefor the pool name given to itbatchSize- the maximum number of events to deliver per batchconfiguration- the framework configuration from which additional components can be retrieved- Returns:
- a new
SubscribableEventSourceconsuming the described persistent stream
-
build
public SubscribableEventSource build(String name, io.axoniq.axonserver.connector.event.PersistentStreamProperties properties, ScheduledExecutorService scheduler, int batchSize, Configuration configuration) Always throws, since a singleScheduledExecutorServiceshared across every tenant would defeat the per-tenant thread isolation this factory exists to provide.- Specified by:
buildin interfacePersistentStreamEventSourceFactory- Parameters:
name- the unique stream name on Axon Serverproperties- the persistent stream properties (segment count, sequencing policy, filter, etc.)scheduler- the scheduled executor to use for this stream's background tasksbatchSize- the maximum number of events to deliver per batchconfiguration- the framework configuration from which additional components can be retrieved- Returns:
- a new
SubscribableEventSourceconsuming the described persistent stream - Throws:
AxonConfigurationException- always, directing the caller to theFunction-basedbuildoverload instead
-