I am using tomcat for my web based application. I want to schedule a task, or rather spon a task and come back to the next page. The problem is, I want to start a task, which will intern make a call to SAP BAPI and client shall get the next screen.
Once the task is finished the thread or object initiating the task shall do all the cleanup.
I dont want to do in some scheduler framework, what i want is to create a simple helper object which will make my SAP call and same time the object shall return back control to servlet container.
Hope i am able to convey my problem properly.
JMS is the answer to yr question dear friend..
No other option :(
I am trying to avoid this, btw any ready to use plugin or framework for tomcat
Or fork a new thread/use thread pool to do it.
As Marco put it, a simple thread from a ThreadPool is the answer to your scenario...
Well, what you can do is maintain a global collection that would contain a list of tasks to be scheduled. The servlet, on recieving the request, must just add the task to be scheduled in the collection and notify a thread that waits for this collection to have some entry into it. This thread will get the tasks from the collection, send them to SAP interface or wherever, remove it from collection and will then WAIT till there is some other entry.
You may use sleep feature of thread instead of wait - if required.
Spawn the thread from the init() of the servlet.
Hope this helps!