public class SagaConfiguration<S> extends Object implements ModuleConfiguration
Modifier and Type | Method and Description |
---|---|
SagaConfiguration<S> |
configureErrorHandler(Function<Configuration,ErrorHandler> errorHandler)
Configures the ErrorHandler to use when an error occurs processing an Event.
|
SagaConfiguration<S> |
configureMessageMonitor(Function<Configuration,MessageMonitor<? super EventMessage<?>>> messageMonitor)
Configures a MessageMonitor to be used to monitor Events processed on by the Saga being configured.
|
SagaConfiguration<S> |
configureRollbackConfiguration(Function<Configuration,RollbackConfiguration> rollbackConfiguration)
Defines the policy to roll back or commit a Unit of Work in case exceptions occur.
|
SagaConfiguration<S> |
configureSagaStore(Function<Configuration,SagaStore<? super S>> sagaStoreBuilder)
Configures the Saga Store to use to store Saga instances of this type.
|
SagaConfiguration<S> |
configureTokenStore(Function<Configuration,TokenStore> tokenStore)
Registers the given
tokenStore for use by a TrackingProcessor for the Saga being configured. |
SagaConfiguration<S> |
configureTrackingProcessor(Function<Configuration,TrackingEventProcessorConfiguration> trackingEventProcessorConfiguration)
Registers the
TrackingEventProcessorConfiguration to use when building the processor for this Saga type. |
SagaConfiguration<S> |
configureTransactionManager(Function<Configuration,TransactionManager> transactionManager)
Defines the Transaction Manager to use when processing Events for this Saga.
|
EventProcessor |
getProcessor()
Returns the processor that processed events for the Saga in this Configuration.
|
AnnotatedSagaManager<S> |
getSagaManager()
Returns the SagaManager responsible for managing the lifecycle and invocation of Saga instances of the type
defined in this Configuration
|
SagaRepository<S> |
getSagaRepository()
Returns the SagaRepository instance used to load Saga instances in this Configuration.
|
SagaStore<? super S> |
getSagaStore()
Returns the Saga Store used by the Saga defined in this Configuration.
|
void |
initialize(Configuration config)
Initialize the module configuration using the given global
config |
SagaConfiguration<S> |
registerHandlerInterceptor(Function<Configuration,MessageHandlerInterceptor<? super EventMessage<?>>> handlerInterceptorBuilder)
Registers the handler interceptor provided by the given
handlerInterceptorBuilder function with
the processor defined in this configuration. |
void |
shutdown()
Invoked prior to shutdown of the application.
|
void |
start()
Invoked when the Configuration is started.
|
static <S> SagaConfiguration<S> |
subscribingSagaManager(Class<S> sagaType)
Initialize a configuration for a Saga of given
sagaType , using a Subscribing Event Processor to process
incoming Events. |
static <S> SagaConfiguration<S> |
subscribingSagaManager(Class<S> sagaType,
Function<Configuration,SubscribableMessageSource<EventMessage<?>>> messageSourceBuilder)
Initialize a configuration for a Saga of given
sagaType , using a Subscribing Event Processor to process
incoming Events from the message source provided by given messageSourceBuilder |
static <S> SagaConfiguration<S> |
subscribingSagaManager(Class<S> sagaType,
Function<Configuration,SubscribableMessageSource<EventMessage<?>>> messageSourceBuilder,
Function<Configuration,EventProcessingStrategy> eventProcessingStrategy)
Initialize a configuration for a Saga of given
sagaType , using a Subscribing Event Processor to process
incoming Events from the message source provided by given messageSourceBuilder . |
static <S> SagaConfiguration<S> |
trackingSagaManager(Class<S> sagaType)
Initialize a configuration for a Saga of given
sagaType , using a Tracking Event Processor to process
incoming Events. |
static <S> SagaConfiguration<S> |
trackingSagaManager(Class<S> sagaType,
Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> messageSourceBuilder)
Initialize a configuration for a Saga of given
sagaType , using a Tracking Event Processor to process
incoming Events from a Message Source provided by given messageSourceBuilder . |
public static <S> SagaConfiguration<S> subscribingSagaManager(Class<S> sagaType)
sagaType
, using a Subscribing Event Processor to process
incoming Events.S
- The type of Saga configured in this configurationsagaType
- The type of Saga to handle events withpublic static <S> SagaConfiguration<S> subscribingSagaManager(Class<S> sagaType, Function<Configuration,SubscribableMessageSource<EventMessage<?>>> messageSourceBuilder)
sagaType
, using a Subscribing Event Processor to process
incoming Events from the message source provided by given messageSourceBuilder
S
- The type of Saga configured in this configurationsagaType
- The type of Saga to handle events withmessageSourceBuilder
- The function providing the message source based on the configurationpublic static <S> SagaConfiguration<S> subscribingSagaManager(Class<S> sagaType, Function<Configuration,SubscribableMessageSource<EventMessage<?>>> messageSourceBuilder, Function<Configuration,EventProcessingStrategy> eventProcessingStrategy)
sagaType
, using a Subscribing Event Processor to process
incoming Events from the message source provided by given messageSourceBuilder
.
This methods allows a custom EventProcessingStrategy
to be provided, in case handlers shouldn't be
invoked in the thread that delivers the message.
S
- The type of Saga configured in this configurationsagaType
- The type of Saga to handle events withmessageSourceBuilder
- The function providing the message source based on the configurationeventProcessingStrategy
- The strategy to use to invoke the event handlers.public static <S> SagaConfiguration<S> trackingSagaManager(Class<S> sagaType)
sagaType
, using a Tracking Event Processor to process
incoming Events. Note that a Token Store should be configured in the global configuration, or the Saga Manager
will default to an in-memory token store, which is not recommended for production environments.S
- The type of Saga configured in this configurationsagaType
- The type of Saga to handle events withpublic static <S> SagaConfiguration<S> trackingSagaManager(Class<S> sagaType, Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> messageSourceBuilder)
sagaType
, using a Tracking Event Processor to process
incoming Events from a Message Source provided by given messageSourceBuilder
. Note that a Token Store
should be configured in the global configuration, or the Saga Manager will default to an in-memory token store,
which is not recommended for production environments.S
- The type of Saga configured in this configurationsagaType
- The type of Saga to handle events withmessageSourceBuilder
- The function providing the message source based on the configurationpublic SagaConfiguration<S> configureSagaStore(Function<Configuration,SagaStore<? super S>> sagaStoreBuilder)
sagaStoreBuilder
- The builder that returns a fully initialized Saga Store instance based on the global
Configurationpublic SagaConfiguration<S> registerHandlerInterceptor(Function<Configuration,MessageHandlerInterceptor<? super EventMessage<?>>> handlerInterceptorBuilder)
handlerInterceptorBuilder
function with
the processor defined in this configuration.handlerInterceptorBuilder
- The function to create the interceptor based on the current configurationpublic SagaConfiguration<S> configureTrackingProcessor(Function<Configuration,TrackingEventProcessorConfiguration> trackingEventProcessorConfiguration)
TrackingEventProcessorConfiguration
to use when building the processor for this Saga type.
Note that the provided configuration is ignored when a subscribing processor is being used.
trackingEventProcessorConfiguration
- The function to create the configuration instancepublic SagaConfiguration<S> configureTokenStore(Function<Configuration,TokenStore> tokenStore)
tokenStore
for use by a TrackingProcessor for the Saga being configured. The
TokenStore is ignored when a Subscribing Processor has been configured.tokenStore
- The function returning a TokenStore based on the given Configurationpublic SagaConfiguration<S> configureErrorHandler(Function<Configuration,ErrorHandler> errorHandler)
The default is to propagate errors, causing the processors to release their token and go into a retry loop.
errorHandler
- The function to create the ErrorHandlerpublic SagaConfiguration<S> configureRollbackConfiguration(Function<Configuration,RollbackConfiguration> rollbackConfiguration)
Defaults to roll back on all exceptions.
rollbackConfiguration
- The function providing the RollbackConfiguration to usepublic SagaConfiguration<S> configureTransactionManager(Function<Configuration,TransactionManager> transactionManager)
Defaults to the Transaction Manager defined in the main Configuration.
transactionManager
- The function providing the TransactionManager to usepublic SagaConfiguration<S> configureMessageMonitor(Function<Configuration,MessageMonitor<? super EventMessage<?>>> messageMonitor)
messageMonitor
- The function to create the MessageMonitorpublic void initialize(Configuration config)
ModuleConfiguration
config
initialize
in interface ModuleConfiguration
config
- the global configuration, providing access to generic componentspublic void start()
ModuleConfiguration
start
in interface ModuleConfiguration
Configuration.start()
public EventProcessor getProcessor()
IllegalStateException
- when this configuration hasn't been initialized yetpublic SagaStore<? super S> getSagaStore()
IllegalStateException
- when this configuration hasn't been initialized yetpublic SagaRepository<S> getSagaRepository()
IllegalStateException
- when this configuration hasn't been initialized yetpublic AnnotatedSagaManager<S> getSagaManager()
IllegalStateException
- when this configuration hasn't been initialized yetpublic void shutdown()
ModuleConfiguration
shutdown
in interface ModuleConfiguration
Configuration.shutdown()
Copyright © 2010–2017. All rights reserved.