0

I have a spring boot app which is used to load data into solr during post construct and retrieve accordingly but i want to make sure solr server is up and running before spring boot app comes up. How can i achieve that? Is there a way to load solr instance in java?

aksh1618
  • 2,245
  • 18
  • 37
  • Welcome to Stack Overflow! You seem to be asking two separate things here, please clarify whether - you want to ensure Solr is running before startup (and fail/wait if it isn't) or - do you want to spawn Solr from the application itself before starting up spring boot? – aksh1618 Jan 17 '20 at 20:44
  • @aksh1618 I want start solr from the application itself before starting the spring boot application so that when the application comes up it loads the data into solr collection – sahana bhat Jan 19 '20 at 07:42

1 Answers1

0

You can use the EmbeddedSolrServer - but that's going to limit your architecture and performance early and is not recommended for production use.

By keeping Solr separate from your application you can scale it as necessary, both to achieve clustered performance and better uptime / fail over support.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • how exactly EmbeddedSolrServer solves my issue?Is it embedded within springboot app or standalone server which is called before starting springboot app? – sahana bhat Jan 19 '20 at 07:50
  • It's embedded into the application. If you just want to delay your springboot app to start until Solr is started in a different thread, that's something else, sorry. In any case I'd try to make your app retry connecting to Solr, as it may lose connectivity to Solr at any time, and that should probably be handled in some way. For startup it might be possible to delay springboot from continuing if there's no service listening on a specific port yet? – MatsLindh Jan 19 '20 at 09:55