Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Register Solr with Eureka

I have 2 Spring apps ("client-app" and "service-app") that are already registered to Eureka (and talk via Feign Client). However, I have to talk to an instance of Solr and I'm forced to hard-code the IP address in the properties file. I would much rather not do this and use Eureka for service-discovery.

Question: Is there a way/plugin to have solr register itself with Eureka, so that clients can then discover it (even if it's programmatically via a start-up listener or some sort)?

I've looked at the solr API and it doesn't seem to have lifecycle listener (onStartUp or onShutdown hooks)

like image 813
Judes Tumuhairwe Avatar asked Jan 16 '17 16:01

Judes Tumuhairwe


1 Answers

You would need a Solr Plugin for this, which is SolrCore aware. That interface method inform is called anytime something interesting happens with a core. Within the implementation of the inform method you would need to register/deregister as a client.

Then you would need to add it to your Solr (Cloud) instance. After that and proper configuration of your plugin, it should work.

like image 83
cheffe Avatar answered Oct 12 '22 08:10

cheffe