0
votes

Is boot a prerequisite to run spring reactor? I am trying to use spring reactor in a regular web application environment. I can see that the reactor configuration is created. Consumers are registered. Notifications are called. Events are NOT fired. What and how to check?

Configuration

    @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();
        }


    }

Registering consumers:

@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);
}
2

2 Answers

0
votes

Spring Boot is not a pre-requisite at all, it simply provides some conveniences when using Spring with Reactor.

There could be any number of things happening. Without any details it's hard to give specific suggestions.

0
votes

Simple answer is NO.
Spring boot is not a pre requisite but it makes your bootstrapping easy.

All you need is project reactor in your classpath to use reactor