I have a Spring Boot application where each instance of the application is a node in a cluster, and each node needs to be able to talk to the other nodes in the cluster to share information. For performance reasons, this cannot happen via HTTP, although the initial contact for each node in the cluster is via an HTTP call.
To make the initial HTTP call, instances need to be able to obtain the port that the other instances are running on so that they can register with each other. This means that each node needs to know what port its Tomcat instance is using.
This works fine if I deploy a WAR file that contains an embedded Tomcat instance. I register an ApplicationListener for the EmbeddedServletContainerInitializedEvent and get the port from the EmbbededServletContainer.
The problem comes when I deploy the WAR file to an already running Tomcat instance. I am unable to find a way to determine what port that Tomcat instance is running on, and the aforementioned event does not fire anymore as the Tomcat instance is already running.
Anyone got any ideas on how to find out what port is being used?