TheOni
TheOni

Reputation: 818

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

Upvotes: 3

Views: 495

Answers (1)

TheOni
TheOni

Reputation: 818

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) {

}

Upvotes: 4

Related Questions