opened
ukjbrown
username_0
This may be a local configuration issue, but the Google Group won't allow me to post a question...

I have a simple Spring Boot application and in it I have the following component:

``` java
@Component
@ComponentScan
@Consumer
public class HelloWorldReactor
{
  @Autowired
  private Reactor reactor;

  @PostConstruct
  public void initialize()
  {
    reactor.notify("hello.world", Event.wrap("Hello, World!"));
  }

  @Selector("hello.world")
  public void handleHelloWorld(Event<String> event)
  {
    System.out.println("Hello, World!");
  }
}
```

When the application runs, the reactor.notify is called but the handleHelloWorld method is not invoked.

If I modify the class as follows, then the application will print "Hello!".

``` java
public class HelloWorldReactor
{
  ...
  @PostConstruct
  public void initialize()
  {
    reactor.on($("hello.world"), ev -> System.out.println("Hello!"));
    reactor.notify("hello.world", Event.wrap("Hello, World!"));
  }
  ...
}
```

Calls to reactor.notify("hello.world", Event.wrap("Hello, World!")); at a later point in the application (i.e. outside the initialize method) work correctly.

I added a breakpoint to ConsumerBeanAutoConfiguration[149] where the annotation scanning happens for Selector, and noticed that the program did not break until after the initialize method had been called, which would suggest that it is being executed in parallel (or after) the bean is wired.

I'm not sure if this is a problem with the annotation scanner, my configuration or Spring in general. I've never experienced this kind of issue with Spring before.

Is this expected behaviour?

Thanks.
@Selector annotation scanner invoked too late in the Spring lifecycle
issue
closed
smaldini
username_1
issue