I have a webapp that is running on two load balanced tomcat servers. What’s the best way for the app to determine which server it’s running on?
While I can tell from a sessionid which server it’s running on (as .jvm1 and .jvm2 get appended), how can I get similar information in a background task (scheduled via Spring’s @Scheduled annotation)?
It might be overkill and if there’s another way it’s probably better, but you might be able to query the tomcat Engine MBean and get it’s
jvmRouteproperty. The MBean is usually calledCatalina:type=EngineorCatalina:type=Engine,service=something(see here for more details).