Search code examples
javahelidon

Helidon background task


I have a @ApplicationScoped bean in my Helidon MP microservice, is there a way to force the creation of the bean at server startup instead at first method call?

I need this bean ready and running just after server startup but every attempt I made it's inconclusive


Solution

  • I found a way to solve it. If your bean observes the initialization of ApplicationScoped it will be instantiated during startup phase. It's a trick but it works fine.

    public void init(@Observes @Initialized(ApplicationScoped.class) Object init) {
    
    }