/** * Returns the processor that processed events for the Saga in this Configuration. * * @return The EventProcessor defined in this Configuration * * @throws IllegalStateException when this configuration hasn't been initialized yet */ public EventProcessor getProcessor() { return eventProcessingConfiguration().eventProcessorByProcessingGroup(processorInfo.getProcessingGroup()) .orElse(null); }
/** * Registers the handler interceptor provided by the given {@code handlerInterceptorBuilder} function with * the processor defined in this configuration. * * @param handlerInterceptorBuilder The function to create the interceptor based on the current configuration * @return this SagaConfiguration instance, ready for further configuration * * @deprecated use {@link EventProcessingConfiguration#registerHandlerInterceptor(String, Function)} instead */ @Deprecated public SagaConfiguration<S> registerHandlerInterceptor( Function<Configuration, MessageHandlerInterceptor<? super EventMessage<?>>> handlerInterceptorBuilder) { if (config != null) { eventProcessingConfiguration().registerHandlerInterceptor(processorInfo.getProcessingGroup(), handlerInterceptorBuilder); } else { handlerInterceptors.add(handlerInterceptorBuilder); } return this; }
@Override public void initialize(Configuration config) { this.config = config; eventProcessingConfiguration().registerHandlerInvoker(processorInfo.getProcessingGroup(), c -> sagaManager.get()); eventProcessingConfiguration().registerTokenStore(processorInfo.getProcessingGroup(), c -> tokenStore.get()); eventProcessingConfiguration().configureMessageMonitor(processorInfo.getProcessingGroup(), c -> (MessageMonitor<Message<?>>) messageMonitor.get()); eventProcessingConfiguration().configureErrorHandler(processorInfo.getProcessingGroup(), c -> errorHandler.get()); eventProcessingConfiguration().configureRollbackConfiguration(processorInfo.getProcessingGroup(), c -> rollbackConfiguration.get()); eventProcessingConfiguration().configureTransactionManager(processorInfo.getProcessingGroup(), c -> transactionManager.get()); handlerInterceptors.forEach(i -> eventProcessingConfiguration() .registerHandlerInterceptor(processorInfo.getProcessingGroup(), i)); if (processorInfo.isCreateNewProcessor()) { switch (processorInfo.getType()) { case TRACKING: eventProcessingConfiguration().registerEventProcessor(processorInfo.getProcessingGroup(), this::buildTrackingEventProcessor); break; case SUBSCRIBING: eventProcessingConfiguration().registerEventProcessor(processorInfo.getProcessingGroup(), this::buildSubscribingEventProcessor); break; default: throw new IllegalStateException("Unsupported event processor type."); } } }