I appear to be losing messages sent to a reactor in my Spring application. I suspect that this is due to the time in the lifecycle of the Spring container that I start to produce messages.
In my particular use case there is a Spring Bean which performs some initialisation on startup. Part of this initialisation involves producing a message that is sent to the Reactor.
I suspect that there is an issue with the order that Spring is registering consumers and that the initialisation code has run before the consumers have been registered. If I run the code manually after startup, e.g. make a request to a controller which calls the same code then the messages make it to the consumer.
I tried various ways of changing the time in the lifecycle that the initialisation code runs, e.g. ApplicationListener<ContextRefreshedEvent>
, ApplicationListener<ContextStartedEvent>
, @PostConstruct
method, implementing InitializingBean
and so on. None of these approaches appear to work.
My consumers are annotated with @reactor.spring.annotation.Consumer and the methods with @reactor.spring.annotation.Selector.Just in case it is relevant, I am using Spring Boot and the auto-configured Reactor (@EnableReactor).