Roger Sterling wrote:You should have an asynchronous message processing engine that receives JMS updates from your analyzer.
Roger Sterling wrote:You can do anything you want, you are the developer. Like as in any possible problem, there can be twelve different solutions. If you do not want to use JMS, you don't have to. You can use any of the solutions you mentioned.
Roger Sterling wrote:Does this look easy or hard to you ? http://www.eaipatterns.com/RequestReplyJmsExample.html
And how can I check if the process if finished with AJAX?
I don't see servlet async processing as a good fit for this. After some hours the web page where the task was started is likely to have been closed. JMS wouldn't strike me as the first choice here, but that depends on the details of your situation (about which we know very little). What I would recommend is a separate page where the user can go to see the status of all the jobs he has started.
rohit chavan wrote:You can define a hashmap where you have in-memory status of the analyzer.
(I am guessing there can be more than one users.)
1. In you analyzer component, you can set the status as "running" for "Analyzer1" and so on, when the user takes action on it.
2. Then whenever user wants to query the status you can get it from the map.
3. Update the status as complete when the report is generated (i.e. the analyzer component /method call ends)
Milindu Sanoj Kumarage wrote:Can a servlet ask the Replier if it's done that task given to it? or I have to use a workaround like updating a database record once the analyzing is done and where the AJAX request responding servlet checks the database records to know the process's status?
I'm asking how to implement this someone. What should I use? I know I can't start a separate thread and assign this task to it.
Ulf Dittmer wrote:
You can't? Yes, some people will tell you that you should not start new threads in a servlet container or JEE container, but the fact is, it's not an uncommon thing to do, and it generally works fine. There are some interesting classes in the java.util.concurrent package that might help, like ExecutorService.
If there are a lot of these tasks, or they're running in parallel, then you may want to come up with a scheme of how to send the tasks to some other server, maybe via some kind of queue, as was mentioned before.
Rob Spoor wrote:If you're stuck with JEE6, there are other ways. Using TimerService can be used to create delayed or recurring tasks, optionally in combination with ScheduleExpression. To run something in the background you can use JMS or @Asynchronous. For the latter, simply annotate a bean with that, get a reference to the bean*, and call the @Asynchronous method.
* If you want to call a method of the bean itself as an @Asynchronous method, you can use SessionContext's getBusinessObject method to get a bean reference from the bean itself.
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton