Re: What is the proper way to start a secondary process in Wicket 6
Dear All, With the invaluable help of Martin Grigorov, I have summarized the discussion on this thread on a small Wicket in Action article [1]. The complete sample project can be found at [2]. 1- http://wicketinaction.com/2014/07/working-with-background-jobs/ 2-https://github.com/reiern70/antilia-bits/tree/master/bgprocess On Tue, Nov 25, 2014 at 6:30 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: @Martin, Many thanks! I will try to have a look today at the PR and see if I find the time to write the blogs article during this week. Thanks again! On Mon, Nov 24, 2014 at 5:46 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi Ernesto, See https://github.com/reiern70/antilia-bits/pull/1 I've moved the code that exports the Application thread local to TasksRunnable. This way it is possible to export the Session too. The code looks good (after removing all annoying whitespaces :-) ). Now it needs some explanation (i.e. blog article) ;-) Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sun, Nov 23, 2014 at 8:13 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, ThreadContext.detach(); seems to be more proper than... ThreadContext.setApplication(null); I will update demo. On Sat, Nov 22, 2014 at 10:58 PM, Warren Bell warrenbe...@gmail.com wrote: Ernesto, That’s kind of what I ended up doing except with a different ThreadPoolExecutor implementation. ExecutorService executorService = new ScheduledThreadPoolExecutor(20) { @Override protected void beforeExecute(Thread t, Runnable r) { ThreadContext.setApplication(MyApplication.this); } @Override protected void afterExecute(Runnable r, Throwable t) { ThreadContext.detach(); } }; No particular reason why I picked ScheduledThreadPoolExecutor other than it looked a little easier to use. I need to look more into the different types of Thread pools and such. I used: ThreadContext.detach(); instead of: ThreadContext.setApplication(null); Warren Bell On Nov 22, 2014, at 11:18 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: pushed a new version including injecting a Guice managed service class On Sat, Nov 22, 2014 at 8:08 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, Something like: ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueueRunnable()) { @Override protected void beforeExecute(final Thread t, final Runnable r) { ThreadContext.setApplication(BgProcessApplication.this); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { ThreadContext.setApplication(null); } }; seems to work. On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ?
Re: What is the proper way to start a secondary process in Wicket 6
Thanks Ernesto ! François Meillet Le 5 janv. 2015 à 10:38, Ernesto Reinaldo Barreiro reier...@gmail.com a écrit : Martin
Re: What is the proper way to start a secondary process in Wicket 6
De rien! 2015-01-05 9:54 GMT+00:00 Francois Meillet francois.meil...@gmail.com: Thanks Ernesto ! François Meillet Le 5 janv. 2015 à 10:38, Ernesto Reinaldo Barreiro reier...@gmail.com a écrit : Martin -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Hi Ernesto, See https://github.com/reiern70/antilia-bits/pull/1 I've moved the code that exports the Application thread local to TasksRunnable. This way it is possible to export the Session too. The code looks good (after removing all annoying whitespaces :-) ). Now it needs some explanation (i.e. blog article) ;-) Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sun, Nov 23, 2014 at 8:13 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, ThreadContext.detach(); seems to be more proper than... ThreadContext.setApplication(null); I will update demo. On Sat, Nov 22, 2014 at 10:58 PM, Warren Bell warrenbe...@gmail.com wrote: Ernesto, That’s kind of what I ended up doing except with a different ThreadPoolExecutor implementation. ExecutorService executorService = new ScheduledThreadPoolExecutor(20) { @Override protected void beforeExecute(Thread t, Runnable r) { ThreadContext.setApplication(MyApplication.this); } @Override protected void afterExecute(Runnable r, Throwable t) { ThreadContext.detach(); } }; No particular reason why I picked ScheduledThreadPoolExecutor other than it looked a little easier to use. I need to look more into the different types of Thread pools and such. I used: ThreadContext.detach(); instead of: ThreadContext.setApplication(null); Warren Bell On Nov 22, 2014, at 11:18 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: pushed a new version including injecting a Guice managed service class On Sat, Nov 22, 2014 at 8:08 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, Something like: ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueueRunnable()) { @Override protected void beforeExecute(final Thread t, final Runnable r) { ThreadContext.setApplication(BgProcessApplication.this); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { ThreadContext.setApplication(null); } }; seems to work. On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto: reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write
Re: What is the proper way to start a secondary process in Wicket 6
@Martin, Many thanks! I will try to have a look today at the PR and see if I find the time to write the blogs article during this week. Thanks again! On Mon, Nov 24, 2014 at 5:46 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi Ernesto, See https://github.com/reiern70/antilia-bits/pull/1 I've moved the code that exports the Application thread local to TasksRunnable. This way it is possible to export the Session too. The code looks good (after removing all annoying whitespaces :-) ). Now it needs some explanation (i.e. blog article) ;-) Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sun, Nov 23, 2014 at 8:13 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, ThreadContext.detach(); seems to be more proper than... ThreadContext.setApplication(null); I will update demo. On Sat, Nov 22, 2014 at 10:58 PM, Warren Bell warrenbe...@gmail.com wrote: Ernesto, That’s kind of what I ended up doing except with a different ThreadPoolExecutor implementation. ExecutorService executorService = new ScheduledThreadPoolExecutor(20) { @Override protected void beforeExecute(Thread t, Runnable r) { ThreadContext.setApplication(MyApplication.this); } @Override protected void afterExecute(Runnable r, Throwable t) { ThreadContext.detach(); } }; No particular reason why I picked ScheduledThreadPoolExecutor other than it looked a little easier to use. I need to look more into the different types of Thread pools and such. I used: ThreadContext.detach(); instead of: ThreadContext.setApplication(null); Warren Bell On Nov 22, 2014, at 11:18 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: pushed a new version including injecting a Guice managed service class On Sat, Nov 22, 2014 at 8:08 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, Something like: ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueueRunnable()) { @Override protected void beforeExecute(final Thread t, final Runnable r) { ThreadContext.setApplication(BgProcessApplication.this); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { ThreadContext.setApplication(null); } }; seems to work. On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto: reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are
Re: What is the proper way to start a secondary process in Wicket 6
Warren, Something like: ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueueRunnable()) { @Override protected void beforeExecute(final Thread t, final Runnable r) { ThreadContext.setApplication(BgProcessApplication.this); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { ThreadContext.setApplication(null); } }; seems to work. On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.com mailto:reier...@gmail.commailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org mailto:mgrigo...@apache.orgmailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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
Re: What is the proper way to start a secondary process in Wicket 6
pushed a new version including injecting a Guice managed service class On Sat, Nov 22, 2014 at 8:08 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, Something like: ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueueRunnable()) { @Override protected void beforeExecute(final Thread t, final Runnable r) { ThreadContext.setApplication(BgProcessApplication.this); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { ThreadContext.setApplication(null); } }; seems to work. On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org mailto:mgrigo...@apache.orgmailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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
Re: What is the proper way to start a secondary process in Wicket 6
Ernesto, That’s kind of what I ended up doing except with a different ThreadPoolExecutor implementation. ExecutorService executorService = new ScheduledThreadPoolExecutor(20) { @Override protected void beforeExecute(Thread t, Runnable r) { ThreadContext.setApplication(MyApplication.this); } @Override protected void afterExecute(Runnable r, Throwable t) { ThreadContext.detach(); } }; No particular reason why I picked ScheduledThreadPoolExecutor other than it looked a little easier to use. I need to look more into the different types of Thread pools and such. I used: ThreadContext.detach(); instead of: ThreadContext.setApplication(null); Warren Bell On Nov 22, 2014, at 11:18 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: pushed a new version including injecting a Guice managed service class On Sat, Nov 22, 2014 at 8:08 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, Something like: ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueueRunnable()) { @Override protected void beforeExecute(final Thread t, final Runnable r) { ThreadContext.setApplication(BgProcessApplication.this); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { ThreadContext.setApplication(null); } }; seems to work. On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org mailto:mgrigo...@apache.orgmailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu,
Re: What is the proper way to start a secondary process in Wicket 6
Warren, ThreadContext.detach(); seems to be more proper than... ThreadContext.setApplication(null); I will update demo. On Sat, Nov 22, 2014 at 10:58 PM, Warren Bell warrenbe...@gmail.com wrote: Ernesto, That’s kind of what I ended up doing except with a different ThreadPoolExecutor implementation. ExecutorService executorService = new ScheduledThreadPoolExecutor(20) { @Override protected void beforeExecute(Thread t, Runnable r) { ThreadContext.setApplication(MyApplication.this); } @Override protected void afterExecute(Runnable r, Throwable t) { ThreadContext.detach(); } }; No particular reason why I picked ScheduledThreadPoolExecutor other than it looked a little easier to use. I need to look more into the different types of Thread pools and such. I used: ThreadContext.detach(); instead of: ThreadContext.setApplication(null); Warren Bell On Nov 22, 2014, at 11:18 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: pushed a new version including injecting a Guice managed service class On Sat, Nov 22, 2014 at 8:08 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Warren, Something like: ExecutorService executorService = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueueRunnable()) { @Override protected void beforeExecute(final Thread t, final Runnable r) { ThreadContext.setApplication(BgProcessApplication.this); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { ThreadContext.setApplication(null); } }; seems to work. On Thu, Nov 20, 2014 at 8:33 PM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto: reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto: reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org mailto:mgrigo...@apache.orgmailto:mgrigo...@apache.org
Re: What is the proper way to start a secondary process in Wicket 6
Hi Ernesto, I'm traveling now. I'll be able to take a look at Sunday. On Nov 20, 2014 3:48 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Thanks for your answer! There is no hurry. I will add a service to the mix to cover Warrent use case. Eg using Guice integration. On 21 Nov 2014 09:34, Martin Grigorov mgrigo...@apache.org wrote: Hi Ernesto, I'm traveling now. I'll be able to take a look at Sunday. On Nov 20, 2014 3:48 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
@Warren, Apologies for the extra t on your name: texting on a mobile phone is a pain... I will update de demo to include a service. Just one question: the app not in context is when you try to inject that service? Or because you are using something else from WEB layer? On Fri, Nov 21, 2014 at 11:05 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Thanks for your answer! There is no hurry. I will add a service to the mix to cover Warrent use case. Eg using Guice integration. On 21 Nov 2014 09:34, Martin Grigorov mgrigo...@apache.org wrote: Hi Ernesto, I'm traveling now. I'll be able to take a look at Sunday. On Nov 20, 2014 3:48 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Ernesto, I am not sure that creating a service holder will do the trick without still attaching the app to the new thread. I am currently injecting a service into your ExecutionBridge class that is instantiated in the request thread. All is good until that ExecutionBridge gets passed to the new thread. Injecting the service in a Service holder is the same thing, isn’t it ? I haven’t tried attaching the app to the new thread and injecting the service straight into the new task/thread itself. I think that would be cleaner. I will try that out. Warren Bell On Nov 21, 2014, at 8:19 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: @Warren, Apologies for the extra t on your name: texting on a mobile phone is a pain... I will update de demo to include a service. Just one question: the app not in context is when you try to inject that service? Or because you are using something else from WEB layer? On Fri, Nov 21, 2014 at 11:05 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Thanks for your answer! There is no hurry. I will add a service to the mix to cover Warrent use case. Eg using Guice integration. On 21 Nov 2014 09:34, Martin Grigorov mgrigo...@apache.org wrote: Hi Ernesto, I'm traveling now. I'll be able to take a look at Sunday. On Nov 20, 2014 3:48 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo
Re: What is the proper way to start a secondary process in Wicket 6
Warren, Service holder will be created in a WEB thread, so WebApplication will be in context as a thread local. Mind that cosntructor of servce holder will cal Injector.get().inject... too inject the services. After that unless you need it for something else... you no longer need WebApplicatiion. Also if your sevices has no state Service holder could be a singleton that is created on application init and just shared by all bridges. On Fri, Nov 21, 2014 at 5:53 PM, Warren Bell warrenbe...@gmail.com wrote: Ernesto, I am not sure that creating a service holder will do the trick without still attaching the app to the new thread. I am currently injecting a service into your ExecutionBridge class that is instantiated in the request thread. All is good until that ExecutionBridge gets passed to the new thread. Injecting the service in a Service holder is the same thing, isn’t it ? I haven’t tried attaching the app to the new thread and injecting the service straight into the new task/thread itself. I think that would be cleaner. I will try that out. Warren Bell On Nov 21, 2014, at 8:19 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: @Warren, Apologies for the extra t on your name: texting on a mobile phone is a pain... I will update de demo to include a service. Just one question: the app not in context is when you try to inject that service? Or because you are using something else from WEB layer? On Fri, Nov 21, 2014 at 11:05 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Thanks for your answer! There is no hurry. I will add a service to the mix to cover Warrent use case. Eg using Guice integration. On 21 Nov 2014 09:34, Martin Grigorov mgrigo...@apache.org wrote: Hi Ernesto, I'm traveling now. I'll be able to take a look at Sunday. On Nov 20, 2014 3:48 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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)
Re: What is the proper way to start a secondary process in Wicket 6
Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.orgmailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- Regards - Ernesto Reinaldo Barreiro -- This email was Virus checked by Clark's Nutrition's Astaro Security Gateway.
Re: What is the proper way to start a secondary process in Wicket 6
I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.commailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.orgmailto:mgrigo...@apache.orgmailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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,
Re: What is the proper way to start a secondary process in Wicket 6
After doing a little digging, I found the ThreadContext class. ExecutorService executorService = new ScheduledThreadPoolExecutor(20) { @Override protected void beforeExecute(Thread t, Runnable r) { ThreadContext.setApplication(app); } @Override protected void afterExecute(Runnable r, Throwable t) { ThreadContext.detach(); } }; That got rid of the initial no application attached to current thread …” exception. Is this the correct way of creating a new process when you need to use an injected service in it ? Warren Bell On Nov 20, 2014, at 11:33 AM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.commailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.orgmailto:mgrigo...@apache.orgmailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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
Re: What is the proper way to start a secondary process in Wicket 6
Warren. I just realized that part was missing... Look that when you create an ExecutionBridge you do in in a WEB thread. So you could do something like. class ServcesHolder { @Inject private MyService service; public ServicesHolder() { Injector.get().inject(this); } // setter enad getter. } and class ExecutionBridge { private ServicesHolder hoolder; public ExecutionBridge() { // app will be in context and services injected ass this ei executed in a web thread. this.holder = new ServicesHolder(); } } from there on you could use your services via Services holder... No need to have Application as a thread local. On Thu, Nov 20, 2014 at 7:03 PM, Warren Bell warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.com mailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org mailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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.
Re: What is the proper way to start a secondary process in Wicket 6
I do not see a problem with the approach bellow But I normally op for the solution I posted before. On Thu, Nov 20, 2014 at 9:33 PM, Warren Bell warr...@clarksnutrition.com wrote: After doing a little digging, I found the ThreadContext class. ExecutorService executorService = new ScheduledThreadPoolExecutor(20) { @Override protected void beforeExecute(Thread t, Runnable r) { ThreadContext.setApplication(app); } @Override protected void afterExecute(Runnable r, Throwable t) { ThreadContext.detach(); } }; That got rid of the initial no application attached to current thread …” exception. Is this the correct way of creating a new process when you need to use an injected service in it ? Warren Bell On Nov 20, 2014, at 11:33 AM, Warren Bell warr...@clarksnutrition.com wrote: I have seen this from a 2010 post: final Application app = Application.get(); final ExecutorService service = new ScheduledThreadPoolExecutor(1) { @Override protected void beforeExecute(final Thread t, final Runnable r) { Application.set(app); }; @Override protected void afterExecute(final Runnable r, final Throwable t) { Application.unset(); } }; But there is no more Application#set(app) and Application#unset() in Wicket 6. Does Wicket 6 have some built in way of creating secondary processes, maybe an internal thread pool that can be set-up ? Warren Bell On Nov 20, 2014, at 10:03 AM, Warren Bell warr...@clarksnutrition.com mailto:warr...@clarksnutrition.com wrote: Ernesto, great job putting all that code together so quickly. I cloned your project and cherry picked out the code that I needed, I don’t need all the process progress code you have. I don’t really care what the process progress is or even if it completes ok, just don’t want it holding up my response. I ended up using your ExecutionBridge, TasksRunnable, and ITask classes and interfaces. But I still don’t know where and how to inject my service into this new task/thread or ExecutionBridge without getting this exception: Exception in thread pool-1-thread-1 org.apache.wicket.WicketRuntimeException: There is no application attached to current thread pool-1-thread-1 Do I need to get the application attached to my new threads somehow so I can use my injected service, and if so, how do I do that ? Warren On Nov 20, 2014, at 5:47 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Martin, I have created https://github.com/reiern70/antilia-bits/tree/master/bgprocess My only caveats are https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50 and https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70 I had to re-add Timer behavior: I do not see yet why? It is as if the timer is not re-rendered: they are not isTemporar :-( I will check when I have more time. I would appreciate if you can review the code... before I write anything on my fork of Wicket in Action. This probably could be done in a leaner way mounting a resource to serve JSON for task states and building the UI at client side... But example illustrates how to do it with plain Wicket. On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro reier...@gmail.commailto:reier...@gmail.commailto:reier...@gmail.com wrote: Ok. Let me see what I can do this weekend while I wait for my son to finish he's shower after he's football match ;-) On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov mgrigo...@apache.org mailto:mgrigo...@apache.orgmailto:mgrigo...@apache.org wrote: Sure! Thanks! It could be as fancy as you wish. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Can I give it a try? Something event showing some progress at client side? On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@gmail.com wrote: I am using Wicket 6 REST annotations and want to asynchronously
What is the proper way to start a secondary process in Wicket 6
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. 1) Get request 2) Log some data (Do not wait for this to complete) 3) Process request 4) Return response Thanks, Warren Bell - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: What is the proper way to start a secondary process in Wicket 6
Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro
Re: What is the proper way to start a secondary process in Wicket 6
Hi, Someday I'll write a blog (with a demo) about this at http://wicketinaction.com. The question is being asked regularly. Actually anyone can send a Pull Request at https://github.com/dashorst/wicketinaction.com with such article. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Hi Warren, On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell warrenbe...@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-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro