As you noted, sharing S's ResponseBuilder is not possible because once
the handler's process method is complete, the http action is deemed
complete and the pipe is broken. You cannot send the client any
further responses anymore.

One way to solve this problem is to maintain the state of the job in
the handler and provide a "status" API for clients to poll. This
really has nothing to do with Solr and therefore Solr does not provide
a standard way of doing such things.

On Sat, Aug 17, 2013 at 9:59 PM, Peyman Faratin <pey...@robustlinks.com> wrote:
> Hi
>
> I have subclassed a SearchComponent (call this class S), and would like to 
> implement the following transaction logic:
>
> 1- Client K calls the S's handler
>
> 2- S spawns a thread and immediately acks K using 
> rb.rsp.add("status","complete") then terminates
>
> public void process (ResponseBuilder rb)
>         {
>                 SolrParams params = rb.req.getParams();
>
>                 try{
>                         ExecutorService executorService = 
> Executors.newCachedThreadPool();
>
>                         Processor job = new  Processor(rb);
>
>                         executorService.submit(job);
>                         rb.rsp.add("status","complete");
>
>                 }catch(Exception e) {e.printStackTrace();};
>         }
>
> 3- The thread S started ("job" above) does two chunks of logic in serial 
> (call these B and C):
>
>         i) B does some processing and sends client K a series of status 
> updates, then
>         ii) C does some processing and in turn sends K series of status 
> updates then one final complete message
>         iii)  transaction ends
>
> I am using SOLR 4.3.1. How can I support such a transaction in solr? I've 
> tried sharing S's ResponseBuilder with the thread but presumably because S 
> terminates in step 2 K will never see the response from B and C. In general I 
> would like to implement a mechanism that can share processing state with the 
> client in the same http session.
>
> thank you for your help
>
> Peyman
>
>



-- 
Regards,
Shalin Shekhar Mangar.

Reply via email to