wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ernesto Reinaldo Barreiro <reier...@gmail.com>
Subject Re: What is the proper way to start a secondary process in Wicket 6
Date Thu, 20 Nov 2014 05:26:44 GMT
Hi Warren,


On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell <warrenbell2@gmail.com> wrote:

> I am using Wicket 6 REST annotations and want to asynchronously start a
> process that writes some logging data to a db. I don’t need the response to
> wait for this process. I have tried using threads, but I get the “App not
> attached to this thread” exception when I try to use an injected service.
> This logging process is a little more complicated than what log4j or
> loopback can do. The bottom line is that I do not want the request/response
> process to have to wait for the logging process to complete. What is the
> proper way of doing this in Wicket 6 using an injected service.
>
> Sometimes  what I do is I create a context class ServiceHolder, inject
what I need on this class (e.g. services) and pass this to the non web
thread (e.g as an argument to the runnable). Injector.inject will have
WicketApp in context.


> 1) Get request
> 2) Log some data (Do not wait for this to complete)
> 3) Process request
> 4) Return response
>

You could use the same ServiceHolder as a bridge to pass info to the WEB
layer. 1) keep a reference to it 2) in another (polling) request use it to
see how back-ground job is progressing. Sometimes I also use it to control
the Job: e.g. stop/pause it, cancel it. Once Job finishes just let service
holder "go".


> Thanks,
>
> Warren Bell
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message