You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Otis Gospodnetic <ot...@gmail.com> on 2013/06/17 22:03:37 UTC
Start custom Java component on Solr start?
Hi,
What is the best thing in Solr to hook into that would allow me to
start (and keep running) a custom piece of code when Solr starts? Say
I want to have something that pulls data from an external queue from
within Solr and indexes it into Solr and I want it start and stop
together with the Solr process. Is there any place in Solr where one
could do that?
Thanks,
Otis
--
Solr & ElasticSearch Support
http://sematext.com/
Re: Start custom Java component on Solr start?
Posted by Chris Hostetter <ho...@fucit.org>.
: What is the best thing in Solr to hook into that would allow me to
: start (and keep running) a custom piece of code when Solr starts? Say
: I want to have something that pulls data from an external queue from
: within Solr and indexes it into Solr and I want it start and stop
: together with the Solr process. Is there any place in Solr where one
: could do that?
My advice for this has always been a SolrCoreAware RequestHandler which
spun up whatever threads it needs in it's init method and uses it's
handleRequest method to return status information or recieve commands
about pausing.
This approach has worked very well for me in the past, oging as far back
as Solr 1.0 -- which was before we even had the SolrCoreAware interface, i
used a newSearcher listener back then to fire a "start" command to my
custom RequestHandler.
-Hoss
Re: Start custom Java component on Solr start?
Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
I assume you don't want it per-core. Custom CoreAdminHandler maybe?
On Tue, Jun 18, 2013 at 1:33 AM, Otis Gospodnetic <
otis.gospodnetic@gmail.com> wrote:
> Hi,
>
> What is the best thing in Solr to hook into that would allow me to
> start (and keep running) a custom piece of code when Solr starts? Say
> I want to have something that pulls data from an external queue from
> within Solr and indexes it into Solr and I want it start and stop
> together with the Solr process. Is there any place in Solr where one
> could do that?
>
> Thanks,
> Otis
> --
> Solr & ElasticSearch Support
> http://sematext.com/
>
--
Regards,
Shalin Shekhar Mangar.
Re: Start custom Java component on Solr start?
Posted by Otis Gospodnetic <ot...@gmail.com>.
Hi,
Hm, right, although once Solr stops being a webapp, this won't work any more...
Otis
--
Solr & ElasticSearch Support
http://sematext.com/
On Mon, Jun 17, 2013 at 4:14 PM, Al Wold <al...@alwold.com> wrote:
> I've used a servlet context listener before and it works pretty well. You just have a write a small Java class to receive the event when the app is started, then add it to web.xml.
>
> I don't think there's much good official documentation, but this blog post outlines it pretty simply:
>
> http://www.mkyong.com/servlet/what-is-listener-servletcontextlistener-example/
>
> -Al
>
> On Jun 17, 2013, at 1:03 PM, Otis Gospodnetic wrote:
>
>> Hi,
>>
>> What is the best thing in Solr to hook into that would allow me to
>> start (and keep running) a custom piece of code when Solr starts? Say
>> I want to have something that pulls data from an external queue from
>> within Solr and indexes it into Solr and I want it start and stop
>> together with the Solr process. Is there any place in Solr where one
>> could do that?
>>
>> Thanks,
>> Otis
>> --
>> Solr & ElasticSearch Support
>> http://sematext.com/
>
Re: Start custom Java component on Solr start?
Posted by Al Wold <al...@alwold.com>.
I've used a servlet context listener before and it works pretty well. You just have a write a small Java class to receive the event when the app is started, then add it to web.xml.
I don't think there's much good official documentation, but this blog post outlines it pretty simply:
http://www.mkyong.com/servlet/what-is-listener-servletcontextlistener-example/
-Al
On Jun 17, 2013, at 1:03 PM, Otis Gospodnetic wrote:
> Hi,
>
> What is the best thing in Solr to hook into that would allow me to
> start (and keep running) a custom piece of code when Solr starts? Say
> I want to have something that pulls data from an external queue from
> within Solr and indexes it into Solr and I want it start and stop
> together with the Solr process. Is there any place in Solr where one
> could do that?
>
> Thanks,
> Otis
> --
> Solr & ElasticSearch Support
> http://sematext.com/