• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Handle large process by Maintain status in presentation

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic