@Override public String processingGroup() { ensureInitialized(); return config.eventProcessingConfiguration() .sagaProcessingGroup(configurer.type); }
/** * Builds the configuration and starts it immediately. It is not recommended to change any configuration on this * Configurer once this method is called. * * @return The started configuration */ default Configuration start() { Configuration configuration = buildConfiguration(); configuration.start(); return configuration; } }
@Override public ListenerInvocationErrorHandler listenerInvocationErrorHandler() { ensureInitialized(); return config.eventProcessingConfiguration() .listenerInvocationErrorHandler(processingGroup()); }
/** * Configures an Aggregate using default settings. This means the aggregate is expected to be Event Sourced if an * Event Store present in the configuration. Otherwise, an explicit repository must be configured and the * {@link #configureAggregate(AggregateConfiguration)} must be used to register the aggregate. * * @param aggregate The aggregate type to register with the Configuration * @param <A> The type of aggregate * @return the current instance of the Configurer, for chaining purposes */ default <A> Configurer configureAggregate(Class<A> aggregate) { return configureAggregate(AggregateConfigurer.defaultConfiguration(aggregate)); }
/** * Prepare the registered modules for initialization. This ensures all lifecycle handlers are registered. */ protected void prepareModules() { modules.forEach(module -> { initHandlers.add(new ConsumerHandler(module.phase(), module::initialize)); startHandlers.add(new RunnableHandler(module.phase(), module::start)); shutdownHandlers.add(new RunnableHandler(module.phase(), module::shutdown)); }); }
/** * Registers a {@link Function} that builds an Event Handler instance. * * @param eventHandlerBuilder a {@link Function} that builds an Event Handler instance. * @return the current instance of the Configurer, for chaining purposes. */ default Configurer registerEventHandler(Function<Configuration, Object> eventHandlerBuilder) { eventProcessing().registerEventHandler(eventHandlerBuilder); return this; }
/** * Configures the given Transaction Manager to use in this configuration. The builder receives the Configuration as * input and is expected to return a fully initialized {@link TransactionManager} * instance. * * @param transactionManagerBuilder The builder function for the {@link TransactionManager} * @return the current instance of the Configurer, for chaining purposes */ default Configurer configureTransactionManager(Function<Configuration, TransactionManager> transactionManagerBuilder) { return registerComponent(TransactionManager.class, transactionManagerBuilder); }
@Override public AbstractSagaManager<S> manager() { ensureInitialized(); return manager.get(); }
@Override public SagaStore sagaStore() { ensureInitialized(); return sagaStore.get(); }
@Override public void afterPropertiesSet() { if (!initialized) { initialized = true; eventProcessingConfiguration.initialize(axonConfiguration); } } }
/** * Obtains an Saga {@link EventProcessor} implementation for the given {@code sagaType}. * * @param sagaType the type of Saga for which to get the Event Processor * @param <T> the type of the expected {@link EventProcessor} * @return an {@link Optional} specifying whether an {@link EventProcessor} for the given {@link SagaConfiguration} * exists */ default <T extends EventProcessor> Optional<T> sagaEventProcessor(Class<?> sagaType) { return eventProcessorByProcessingGroup(sagaProcessingGroup(sagaType)); }
@Override public Configurer configureEventSerializer(Function<Configuration, Serializer> eventSerializerBuilder) { eventSerializer.update(eventSerializerBuilder); return this; }
@Override public Configurer configureMessageMonitor(Class<?> componentType, MessageMonitorFactory messageMonitorFactory) { messageMonitorFactoryBuilder.add(componentType, messageMonitorFactory); return this; }
@Override public void stop() { eventProcessingConfiguration.shutdown(); running = false; }
/** * Configures the given Resource Injector to use for Sagas in this configuration. The builder receives the * Configuration as input and is expected to return a fully initialized {@link ResourceInjector} instance. * * @param resourceInjectorBuilder The builder function for the {@link ResourceInjector} * @return the current instance of the Configurer, for chaining purposes */ default Configurer configureResourceInjector(Function<Configuration, ResourceInjector> resourceInjectorBuilder) { return registerComponent(ResourceInjector.class, resourceInjectorBuilder); }
@Override public SagaStore<? super S> store() { ensureInitialized(); return store.get(); }
@Override public Configurer configureMessageSerializer(Function<Configuration, Serializer> messageSerializerBuilder) { messageSerializer.update(messageSerializerBuilder); return this; }
@Override public Configurer configureMessageMonitor(Class<?> componentType, String componentName, MessageMonitorFactory messageMonitorFactory) { messageMonitorFactoryBuilder.add(componentType, componentName, messageMonitorFactory); return this; }
@Override public SagaRepository<S> repository() { ensureInitialized(); return repository.get(); }
@Override public EventProcessingConfigurer registerDefaultErrorHandler( Function<Configuration, ErrorHandler> errorHandlerBuilder) { this.defaultErrorHandler.update(errorHandlerBuilder); return this; }