/** * Register a subscribing event processor with given {@code name} that subscribes to the given {@code * messageSource}. This allows the use of standard Subscribing Event Processors that listen to another source than * the Event Bus. * * @param name The name of the Event Processor * @param messageSource The source the processor should read from * @return event processing configuration for chaining purposes */ public EventProcessingConfiguration registerSubscribingEventProcessor(String name, Function<Configuration, SubscribableMessageSource<? extends EventMessage<?>>> messageSource) { registerEventProcessor(name, (n, c, ehi) -> subscribingEventProcessor(n, c, ehi, messageSource)); return this; }
/** * Registers a TrackingEventProcessor with the given {@code name}, reading from the given {@code source} and using * the given {@code processorConfiguration}. * * @param name The name of the Tracking Processor * @param source The source to read Events from * @param processorConfiguration The configuration for the processor * @return event processing configuration for chaining purposes */ public EventProcessingConfiguration registerTrackingEventProcessor(String name, Function<Configuration, StreamableMessageSource<TrackedEventMessage<?>>> source, Function<Configuration, TrackingEventProcessorConfiguration> processorConfiguration) { registerEventProcessor(name, (n, c, ehi) -> trackingEventProcessor(c, n, ehi, processorConfiguration, source)); return this; }
/** * Defines the Event Processor builder for an Event Processor with the given {@code name}. Event Processors * registered using this method have priority over those defined in * {@link #registerEventProcessorFactory(EventProcessorBuilder)}. * <p> * The given builder is expected to create a fully initialized Event Processor implementation based on the name and * list of event handler beans. The builder also received the global configuration instance, from which it can * retrieve components. * <p> * Note that the processor must be initialized, but shouldn't be started yet. The processor's * {@link EventProcessor#start()} method is invoked when the global configuration is started. * * @param name The name of the Event Processor for which to use this builder * @param eventProcessorBuilder The builder function for the Event Processor * @return this EventHandlingConfiguration instance for further configuration * @deprecated use {@link EventProcessingConfiguration#registerEventProcessor(String, * EventProcessingConfiguration.EventProcessorBuilder)} instead */ @Deprecated public EventHandlingConfiguration registerEventProcessor(String name, EventProcessorBuilder eventProcessorBuilder) { eventProcessorBuilders.put(name, (config, handlers) -> config .eventProcessingConfiguration() .registerEventProcessor(name, (n, c, ehi) -> eventProcessorBuilder.createEventProcessor(c, n, handlers))); return this; }
/** * Registers a TrackingProcessor with the given {@code name}, reading from the given {@code source} and using the * given {@code processorConfiguration}. The given {@code sequencingPolicy} defines the policy for events that need * to be executed sequentially. * * @param name The name of the Tracking Processor * @param source The source to read Events from * @param processorConfiguration The configuration for the processor * @param sequencingPolicy The sequencing policy to apply when processing events in parallel * @return this EventHandlingConfiguration instance for further configuration * @deprecated use {@link EventProcessingConfiguration#registerTrackingEventProcessor(String, Function, Function)} instead */ @Deprecated public EventHandlingConfiguration registerTrackingProcessor(String name, Function<Configuration, StreamableMessageSource<TrackedEventMessage<?>>> source, Function<Configuration, TrackingEventProcessorConfiguration> processorConfiguration, Function<Configuration, SequencingPolicy<? super EventMessage<?>>> sequencingPolicy) { eventProcessorBuilders.put(name, (conf, handlers) -> conf.eventProcessingConfiguration() .registerEventProcessor(name, (n, c, ehi) -> buildTrackingEventProcessor(c, n, handlers, processorConfiguration, source, sequencingPolicy))); 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."); } } }