I have to update some data in my local DB during user web session. Information, by which I will update my data, I will get by batch of http requests, which are executed for more then 2 sec - for user iteraction with application it's impossible. So I have to implement something like a backend threads by an technology in J2ee env.
I have weblogic 8.1 (sdk 1.4)
Use some kind of job scheduler that will trigger its data crunching job frequently, for examlpe Quartz. Or perhaps simply a TimerBean.
To be more specific:
1. User request comes in with neccessary data or issue. Store that in the simplest way. Tell the user that the work is in progress, and to come back in x minutes.
2. The job kicks in and does its work. When done, it writes a persistant flag in the db telling that the job is done.
3. If the user comes back before that flag is set, tell him to hold on and come back later.
4. If the user comes back when the job is done, all is fine!
If you are using weblogic 8.1, why not make use of JMS rather than spawning seperate backend threads and so on.
1. Use a JMS queue which can take the requests that you need to write to a database. (Based on your priority, you can make this queue persistent/non-persistent)
2. Have a program which will dequeue from this JMS queue and write them offline to the database.
3. If you want, you can publish the result of database updates to another queue (when ever a user comes back, you can poll this queue for a specific selectorId)
I believe that JMS is heavy-weight solution, JMS use-cases could be: integrate parts of the system or components of 2 different enterprises,
but I think for simple things it is not the best solution...
So, OpenSymphony's Quartz seems very useful and flexible enough - it can use RAM (Memory) storage or JDBC storage, as you wish.