启动是运行弹簧反应器的先决条件吗?我正在尝试在常规 Web 应用程序环境中使用 spring reactor。我可以看到反应器配置已创建。消费者已注册。通知被调用。事件不会被触发。什么以及如何检查?
配置
@Configuration
@EnableReactor
public class ReactorConfiguration {
@Bean
Environment env() {
return new Environment();
}
@Bean
Reactor createReactor(Environment env) {
return Reactors.reactor().env(env).dispatcher(Environment.THREAD_POOL)
.get();
}
}
注册消费者:
@PostConstruct
public void onStartUp() {
logger.debug("Registering Consumers");
reactor.on(Selectors.T(Envelope.class), processParentRequest());
reactor.on(Selectors.T(Bundle.class), processOptimizerRequest());
reactor.on(Selectors.$(Constants.LOWER_ASG), processLowerAsgsRequest());
reactor.on(Selectors.$(constants.SET_CONSUMPTION_LEVEL),
processConsumersRequest());
reactor.on(Selectors.$(constants.SET_GENERATION_LEVEL),
processProducersRequest());
reactor.on(Selectors.$(constants.SET_STORAGE_SUPPLY_LEVEL),
processStoragesRequest());
}
private Consumer<Event<Envelope>> processParentRequest() {
return envelope -> optimizerUpdatingService
.processParentRequest(envelope);
}
private Consumer<Event<Bundle>> processOptimizerRequest() {
return bundle -> eventProcessingDispenser
.processOptimizerRequest(bundle);
}
private Consumer<Event<Envelope>> processLowerAsgsRequest() {
return envelope -> lowerAsgsProcessingService
.processLowerAsgRequest(envelope);
}
private Consumer<Event<Message>> processConsumersRequest() {
return message -> consumersProcessingService
.processConsumersRequest(message);
}
private Consumer<Event<Message>> processProducersRequest() {
return message -> producersProcessingService
.processProducersRequest(message);
}
private Consumer<Event<Message>> processStoragesRequest() {
return message -> storageProcessingService
.processStoragesRequest(message);
}