I have application deployed on Tomcat and I need to process long running
request. When I start processing my application becomes blocked. Is
there any way to workaround this situation?
I am taking into consideration using threads but I need to inform user
about request status…
Maybe there is a possibility to tune tomcat or something
We run background jobs in threads, and that seems to work great. You
could
also put your requests in a JMS queue to a processor that handles the
jobs.
Typically we write status to a shared resource (e.g. database or file).
You
then expose this resource (rails controller) and poll for the status
with
javascript.
When you say the application becomes “blocked” do you mean that it just
takes a long time to process the request and for the user to see a
response
or does your application not handle any more requests at all?
We run background jobs in threads, and that seems to work great. You
could
also put your requests in a JMS queue to a processor that handles the
jobs.
Typically we write status to a shared resource (e.g. database or file).
You
then expose this resource (rails controller) and poll for the status
with
javascript.
-Justin
Hi Justin,
Could you please elaborate more about how to inform user when his job is
done? I mean… if you put your job in background you simply end request
(Am I right?). How can I inform browser about job status? My idea was to
run ajax inquiry and try to check status every X seconds.
When you say the application becomes “blocked” do you mean that it just
takes a long time to process the request and for the user to see a
response
or does your application not handle any more requests at all?
I have application deployed on Tomcat and I need to process long running
request. When I start processing my application becomes blocked. Is
there any way to workaround this situation?
I am taking into consideration using threads but I need to inform user
about request status…
Maybe there is a possibility to tune tomcat or something
Perhaps you can signal QUIT or send Ctrl+\ to the Tomcat process to
see where it’s blocking? It sounds like either the available threads
in Tomcat’s pool are getting used up or there’s some other resource in
your application being contended for (or acquired and not released).
Could you please elaborate more about how to inform user when his job is
done? I mean… if you put your job in background you simply end request
(Am I right?). How can I inform browser about job status? My idea was to
run ajax inquiry and try to check status every X seconds.
Yes, you do end the primary request. However, subsequent ajax requests
are
able to check and report the status. If you’re using prototype.js you
can
use: