I have a scenario where we have two dispatcher servlet in our web.xml file.
One of the dispatcher servlet mentioned below have very minimal beans and starts quickly and pass health check and notifies the load balancer thats its ready to serve traffic.
The other dispatcher servlet is heavyweight and has lots of beans and takes almost 1~2 min to initialize.
we want to make sure the first dispatcher only sends a request to load balancer thats its ready to serve traffic once all the spring beans are initialized in the second dispatcher.
some solution which i have on top of my head is
Let the content controller implements InitializingBean and in the afterPropertiesSet() method is fired set a flag as true and expose that as a JMX property.
The healthcheck controller will first check the property exposed as a jmx bean and only send signal to load balancer that its ready to server traffic only if the flag is true.
Is there a way i can defer loading of bean in healthcheck controller by like 2 min or so.