@Override public List<CorrelationDataProvider> correlationDataProviders() { return config.correlationDataProviders(); }
private EventProcessor buildEventProcessor(List<Function<Configuration, EventHandlerInvoker>> builderFunctions, String processorName) { List<EventHandlerInvoker> invokers = builderFunctions .stream() .map(invokerBuilder -> invokerBuilder.apply(configuration)) .collect(Collectors.toList()); MultiEventHandlerInvoker multiEventHandlerInvoker = new MultiEventHandlerInvoker(invokers); EventProcessor eventProcessor = eventProcessorBuilders .getOrDefault(processorName, defaultEventProcessorBuilder) .build(processorName, configuration, multiEventHandlerInvoker); handlerInterceptorsBuilders.getOrDefault(processorName, new ArrayList<>()) .stream() .map(hi -> hi.apply(configuration)) .forEach(eventProcessor::registerHandlerInterceptor); defaultHandlerInterceptors.stream() .map(f -> f.apply(configuration, processorName)) .filter(Objects::nonNull) .forEach(eventProcessor::registerHandlerInterceptor); eventProcessor.registerHandlerInterceptor(new CorrelationDataInterceptor<>(configuration .correlationDataProviders())); return eventProcessor; }
/** * Provides the default CommandBus implementation. Subclasses may override this method to provide their own default. * * @param config The configuration based on which the component is initialized. * @return The default CommandBus to use. */ protected CommandBus defaultCommandBus(Configuration config) { SimpleCommandBus commandBus = SimpleCommandBus.builder() .transactionManager(config.getComponent(TransactionManager.class, () -> NoTransactionManager.INSTANCE)) .messageMonitor(config.messageMonitor(SimpleCommandBus.class, "commandBus")) .build(); commandBus.registerHandlerInterceptor(new CorrelationDataInterceptor<>(config.correlationDataProviders())); return commandBus; }
/** * Returns the list of Message Handler Interceptors registered for the given {@code processorName}. * * @param configuration The main configuration * @param processorName The name of the processor to retrieve interceptors for * @return a list of Interceptors * @see EventHandlingConfiguration#registerHandlerInterceptor(BiFunction) * @see EventHandlingConfiguration#registerHandlerInterceptor(String, Function) * @deprecated use {@link EventProcessingConfiguration#interceptorsFor(String)} instead */ @Deprecated public List<MessageHandlerInterceptor<? super EventMessage<?>>> interceptorsFor(Configuration configuration, String processorName) { List<MessageHandlerInterceptor<? super EventMessage<?>>> interceptors = new ArrayList<>(); defaultHandlerInterceptors.stream() .map(f -> f.apply(configuration, processorName)) .filter(Objects::nonNull) .forEach(interceptors::add); handlerInterceptors.getOrDefault(processorName, Collections.emptyList()) .stream() .map(f -> f.apply(configuration)) .filter(Objects::nonNull) .forEach(interceptors::add); interceptors.add(new CorrelationDataInterceptor<>(configuration.correlationDataProviders())); return interceptors; }
private EventProcessor buildEventProcessor(List<Function<Configuration, EventHandlerInvoker>> builderFunctions, String processorName) { List<EventHandlerInvoker> invokers = builderFunctions .stream() .map(invokerBuilder -> invokerBuilder.apply(configuration)) .collect(Collectors.toList()); MultiEventHandlerInvoker multiEventHandlerInvoker = new MultiEventHandlerInvoker(invokers); EventProcessor eventProcessor = eventProcessorBuilders .getOrDefault(processorName, defaultEventProcessorBuilder) .build(processorName, configuration, multiEventHandlerInvoker); handlerInterceptorsBuilders.getOrDefault(processorName, new ArrayList<>()) .stream() .map(hi -> hi.apply(configuration)) .forEach(eventProcessor::registerHandlerInterceptor); defaultHandlerInterceptors.stream() .map(f -> f.apply(configuration, processorName)) .filter(Objects::nonNull) .forEach(eventProcessor::registerHandlerInterceptor); eventProcessor.registerHandlerInterceptor(new CorrelationDataInterceptor<>(configuration .correlationDataProviders())); return eventProcessor; }
private SubscribingEventProcessor defaultEventProcessor(String name, Configuration conf, EventHandlerInvoker eventHandlerInvoker) { SubscribingEventProcessor eventProcessor = subscribingEventProcessor(name, conf, eventHandlerInvoker, Configuration::eventBus); eventProcessor.registerInterceptor(new CorrelationDataInterceptor<>(conf.correlationDataProviders())); return eventProcessor; }
private EventProcessor buildSubscribingEventProcessor(String name, Configuration config, EventHandlerInvoker eventHandlerInvoker) { SubscribingEventProcessor subscribingEventProcessor = new SubscribingEventProcessor(name, eventHandlerInvoker, rollbackConfiguration.get(), subscribableMessageSourceBuilder .apply(config), processingStrategy .apply(config), errorHandler.get(), messageMonitor.get()); subscribingEventProcessor .registerInterceptor(new CorrelationDataInterceptor<>(config.correlationDataProviders())); return subscribingEventProcessor; }
/** * Provides the default CommandBus implementation. Subclasses may override this method to provide their own default. * * @param config The configuration based on which the component is initialized. * @return The default CommandBus to use. */ protected CommandBus defaultCommandBus(Configuration config) { SimpleCommandBus cb = new SimpleCommandBus(config.getComponent(TransactionManager.class, () -> NoTransactionManager.INSTANCE), config.messageMonitor(SimpleCommandBus.class, "commandBus")); cb.registerHandlerInterceptor(new CorrelationDataInterceptor<>(config.correlationDataProviders())); return cb; }
/** * Configure the use of Tracking Event Processors, instead of the default Subscribing ones. Tracking processors * work in their own thread(s), making processing asynchronous from the publication process. * <p> * The processor will use the {@link TokenStore} implementation provided in the global Configuration, and will * default to an {@link InMemoryTokenStore} when no Token Store was defined. Note that it is not recommended to use * the in-memory TokenStore in a production environment. * * @param processorConfig The configuration for the processors to use * @return event processing configuration for chaining purposes */ public EventProcessingConfiguration usingTrackingProcessors( Function<Configuration, TrackingEventProcessorConfiguration> processorConfig) { registerEventProcessorFactory( (name, config, ehi) -> { TrackingEventProcessor trackingEventProcessor = trackingEventProcessor(config, name, ehi, processorConfig, Configuration::eventBus); trackingEventProcessor .registerInterceptor(new CorrelationDataInterceptor<>(config.correlationDataProviders())); return trackingEventProcessor; }); return this; }
private EventProcessor buildTrackingEventProcessor(String name, Configuration config, EventHandlerInvoker eventHandlerInvoker) { TrackingEventProcessor trackingEventProcessor = new TrackingEventProcessor(name, eventHandlerInvoker, streamableMessageSourceBuilder .apply(config), tokenStore.get(), transactionManager.get(), messageMonitor.get(), rollbackConfiguration.get(), errorHandler.get(), trackingEventProcessorConfiguration .get()); trackingEventProcessor.registerInterceptor(new CorrelationDataInterceptor<>(config.correlationDataProviders())); return trackingEventProcessor; }
/** * Provides the default CommandBus implementation. Subclasses may override this method to provide their own default. * * @param config The configuration based on which the component is initialized. * @return The default CommandBus to use. */ protected CommandBus defaultCommandBus(Configuration config) { SimpleCommandBus commandBus = SimpleCommandBus.builder() .transactionManager(config.getComponent(TransactionManager.class, () -> NoTransactionManager.INSTANCE)) .messageMonitor(config.messageMonitor(SimpleCommandBus.class, "commandBus")) .build(); commandBus.registerHandlerInterceptor(new CorrelationDataInterceptor<>(config.correlationDataProviders())); return commandBus; }