We’re attempting to use Cluster Bootstrap with a custom discovery class that pulls data about other nodes from Eureka. The connection with Eureka and everything works fine, it returns the data for all instances of the service as expected. However, a Cluster is never able to be created because matchesSelf in SelfAwareJoinDecider checks against the port. The source of the port is pulled from ClusterBootstrap.selfContactPoint, which is set using the port listed in the config. When using a random port, the port listed in config is “0”. This means that matchesSelf will never successfully return, as the random assigned port retrieved from the EurekaServiceDiscovery will never equal 0. Hardcoding a port in the config works, but we’re unable to do that as we will have multiple services with separate ActorSystems running on the same servers. Is there a way around this failure with random ports?
I discovered that SelfAwareJoinDecider.selfContactPoint was able to be overridden. Package-private methods are allowed to be overwritten in classes that extend. I simple overrode the method to return the correct host and port, which allowed the joining to complete successfully. A coworker and I tested this by running the same service on our two computers.