aspose file tools*
The moose likes Java in General and the fly likes Handle large process by Maintain status in presentation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Handle large process by Maintain status in presentation" Watch "Handle large process by Maintain status in presentation" New topic
Author

Handle large process by Maintain status in presentation

G.Sathish kumar
Ranch Hand

Joined: Jul 27, 2009
Posts: 84
Hi

1. I have the sitution to process 10 minutes execution to finish one functional process so i though of putting status like whenever the page is called the status bar show the process completed and i display "Processing" info(so user can go some other pages).
2. i mean internally i need to start the thread so when the thread finish i need to update status in th db like processing to completed.
when user come to page if the status completed then i show the report of the execution.

please let me know do i need use java thread concept for that or any other way?


Thanks
Sathish kumar
SCJP, SCWCD
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 157
1. I have the sitution to process 10 minutes execution to finish one functional process


If you are sure about the time, you can make use of javax.swing.JProgressBar


R6i
James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
You could do your long running process using thread on server side.

Although keep the following in mind:
1. Creating your own threads within a web-application is not recommended, because they will compete with Application Server threads.
2. If you have a few hundred users, can you really afford to start many long running threads on the server side in your web-application. Your application will not scale in such a situation.
G.Sathish kumar
Ranch Hand

Joined: Jul 27, 2009
Posts: 84
but my sitution like 300000 records i need to run statistic mathamatical calculation through java will take 20 minutes around so how can i make my architectures can you please help me.
James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
Will you have many users who will be making this request which will run for long?

If not, you could do it within your app-server itself - although many would say it is not recommended.

In any case - here is an alternative:
Have another java application running alongside your Application Server. When you receive a request for executing that long running process, you tell this java application(via socket or some other mechanism) to do it for you and update the database.

Meanwhile your web page can simply poll the database to see if the process is done or not.
G.Sathish kumar
Ranch Hand

Joined: Jul 27, 2009
Posts: 84
James Ward wrote:
If not, you could do it within your app-server itself - although many would say it is not recommended.

there wont be many users going to run any way i like to develope for many users access the application, moreover your second point
James Ward wrote:
In any case - here is an alternative:
Have another java application running alongside your Application Server. When you receive a request for executing that long running process, you tell this java application(via socket or some other mechanism) to do it for you and update the database.


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
James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
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.
G.Sathish kumar
Ranch Hand

Joined: Jul 27, 2009
Posts: 84
my plan is

create the server socket with some port number and using tcp establish the connection to the server and execute the model method which required around 20 minutes to complete process.
ansynchronously show the status processing in the result page
in the end of execution i update result and status(process completed) to db
so when user come to result page next time it show the status and result of process execution

if i am wrong any where please let me know.
James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
Yes, looks good.


using tcp establish the connection to the server and execute the model method


From Application Server using tcp/client-socket you connect to the Process Servers server-socket to send a message to it. And then return.

The Process Server upon receiving the message, starts a new thread to to do-that-long-running-task. And it continues to listen on server-socket for additional messages.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handle large process by Maintain status in presentation