The Artima Developer Community
Sponsored Link

Java Answers Forum
Listener class

4 replies on 1 page. Most recent reply: Jul 23, 2002 4:32 AM by Prasanna

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Prasanna

Posts: 11
Nickname: pras
Registered: May, 2002

Listener class Posted: Jul 18, 2002 4:13 AM
Reply to this message Reply
Advertisement
I am working in a project that aims to automate a document submission process.For this I have written some Listener class which run continuosly and check for any newly submitted docs.But if the program crashes somehow or there is some problem in the JVM at a later time,how to know???This is a automation project ,so I cannot have somebody checking whether the programs are running or not periodically.Please suggest some thing.
Best regds,
Pras


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Listener class Posted: Jul 18, 2002 5:33 PM
Reply to this message Reply
I think the solution is to write a program that doesn't crash. :-)

Are you not catching some exception? What sort of crash is it? If it is program that is continuously running and you are not careful, you may have some memory leak that is slowly gobbling all the memory. Maybe you can include a bit of code...

Prasanna

Posts: 11
Nickname: pras
Registered: May, 2002

Re: Listener class Posted: Jul 20, 2002 12:36 AM
Reply to this message Reply
Yes I am catching all exceptions but what if the JVM crashes..I mean if the JVM crashes or there is some other problem the control is not going to come to the Exception block ,right??
The program for a polling a particular folder for any new submission is somewaht like this:
while(true)
{
File f=new File(folder);
String [] files=f.listFile[];
if(files.length > 0)//if any file is found
{
//process each entry separately
}
//Catch all exceptions here

}
Hope this clarifies the problem somewhat
Thanx.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Listener class Posted: Jul 20, 2002 6:21 PM
Reply to this message Reply
Well I guess this is general problem that doesn't really have to do with Java or the JVM. The whole OS can crash or freeze, or the computer can get turned off (by a bad pick-up line, for instance), etc.

You can have a cron job running on the machine that periodically checks that your program is doing its thing, but this assumes the machine itself is not crashed.

If the location of the folder you are referring to is on the network, you can have another machine that periodically submits a test document and waits for it to get processed; then that program can send alerts or try to restart the other.

Finally, you can implement your whole system in Jini -- in fact at JavaOne, I saw a talk by a German company that did use Jini for a document processing system. It was very robust and "document processors" (machines running a document-processing Jini service) could be dynamically added to and removed from the system at any time. They had a pretty nifty demo, too. I forget the name of the company, it may have been Procoma, or I may have that name mixed up with another...

Prasanna

Posts: 11
Nickname: pras
Registered: May, 2002

Re: Listener class Posted: Jul 23, 2002 4:32 AM
Reply to this message Reply
Thanx Matt for taking out time for replying.I guess I will write one cron job to keep a watch over my Listener class.As for the Jini solution,I cannot go for it now because of time and resource constraints.But thanx anyway.Perhaps I will explore this option in leisure.
prasanna

Flat View: This topic has 4 replies on 1 page
Topic: how can I get back the vector? Previous Topic   Next Topic Topic: To clear the screen

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use