Can we initialize a global final variable with value from databag

113 views Asked by At

I have to schedule a method with @Scheduled Annotation which only takes a constant variable as a parameter. But I want this constant to be initialized from a databag instead of hard coding it. Is there a way to do it?

I can you timer and it works but I want to know if this is possible.I have tried initializing the variable in PostConstruct annotation but it didn't work either as final variables has to be initialized at declaration

   static final int t ;
   @Scheduled(fixedDelay = t)
   public void pushToSearchPeriodic(){
       publishSearchMessagesAndFlush();
   }

need to avoid hard code variable t.

0

There are 0 answers