i feel it is good idea but the alternate java application what could we can use? i have idea to start the thread in application server itself but you mentioned it not recommended so another java application means how can i take th control on the moment itself=> i mean when user click process how to give response whith out complete the whole process
You need to write this alternate java application. Lets call it Process Server.
When users request is received in Application Server, you inform this Process Server that it has to do so-and-so. And you simply return; and do not wait for the process to be completed.
So for eg: If you communicate with Process Server over a Socket. The Process Server should continuously listen for messages over a Socket. From you Application Server, you send it a message over a Socket, then close the socket and simply return - no waiting.
The Process Server upon receiving the message over Socket, will do-whatever-it-needs-to-do, and update the database. The Process Server itself should do whatever-it-needs-to-do by creating a new thread, so that it can process multiple such requests coming from the Application Server.
NOTE: Socket is only one way to communicate information to the Process Server.
Among other alternatives
- update a database table about your 'Job' - and the Process Server keeps polling that database table, when it finds there is a new 'Job' to process, it starts a thread and starts doing whatever-it-needs-to-do.
- Embed a small http server in Process Server, so that you can make a http call to it to communicate. Process Server should create a new thread upon receiving http request, and return control immediately, so as to not hold the request.