Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
run-at is 2.4 spec and I think Tomcat 4 _IS_NOT_ Servlet 2.4 spec My guess it will work in Tomcat 5.0.X and above. Comments? Mark. --- Dwayne Ghant [EMAIL PROTECTED] wrote: Have fun I hope this helps!!! It should. web-app id='/' servlet servlet-name='hello' servlet-class='test.HelloWorld' load-on-startup/ /servlet /web-app The value is a list of 24-hour times when the servlet should be automatically executed. To run the servlet every 6 hours, you could use: servlet servlet-name='test.HelloWorld' run-at0:00, 6:00, 12:00, 18:00/run-at /servlet Frank W. Zammetti wrote: Your just lending weight to what I said... Don't play with threads in a servlet contain unless your really sure you have to and are really sure you can do it safely :) (I'm not sure I knew init() could be called more than once, certainly I didn't remember when I wrote that, so excellent point) -- Dwayne A. Ghant Application Developer Temple University 215.204. [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
run-at - is not part of the servlet spec. It will not appear in tomcat. -Tim Mark wrote: run-at is 2.4 spec and I think Tomcat 4 _IS_NOT_ Servlet 2.4 spec My guess it will work in Tomcat 5.0.X and above. Comments? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
On Tue, 21 Dec 2004 20:24:25 -0800, Dwayne Ghant [EMAIL PROTECTED] wrote: The alarm is configured as any other servlet, with the addition of the run-at tag. The following configuration runs the servlet every 15 minutes. If the hour is missing, e.g. :15 the service is run at the specified minute. 15 minute configuration servlet name='alarm' servlet-class='test.TestAlarm' run-at:00, :15, :30, :45/run-at /servlet Will be the the RUN-AT-paramter evaluated by Tomcat 5.0x or by anybody else? I implemeted a small testscenario but get no log-output for the service-method: ... servlet servlet-nametimerTest/servlet-name servlet-classde.spoon.report.TimerTestServlet/servlet-class run-at:01, :02, :03, :05, :06/run-at load-on-startup1/load-on-startup /servlet ... ... public class TimerTestServlet extends HttpServlet { private final static Logger logger = Logger.getLogger(TimerTestServlet.class); public void init(ServletConfig config) throws ServletException { super.init(config); logger.info(INIT: + new Date()); } public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info(SERVICE: + new Date()); } } Did i something wrong? Regards, Thomas. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
run-at is resin specific (non servlet compliant extension) -Tim Thomas Chille wrote: On Tue, 21 Dec 2004 20:24:25 -0800, Dwayne Ghant [EMAIL PROTECTED] wrote: The alarm is configured as any other servlet, with the addition of the run-at tag. The following configuration runs the servlet every 15 minutes. If the hour is missing, e.g. :15 the service is run at the specified minute. 15 minute configuration servlet name='alarm' servlet-class='test.TestAlarm' run-at:00, :15, :30, :45/run-at /servlet Will be the the RUN-AT-paramter evaluated by Tomcat 5.0x or by anybody else? I implemeted a small testscenario but get no log-output for the service-method: ... servlet servlet-nametimerTest/servlet-name servlet-classde.spoon.report.TimerTestServlet/servlet-class run-at:01, :02, :03, :05, :06/run-at load-on-startup1/load-on-startup /servlet ... ... public class TimerTestServlet extends HttpServlet { private final static Logger logger = Logger.getLogger(TimerTestServlet.class); public void init(ServletConfig config) throws ServletException { super.init(config); logger.info(INIT: + new Date()); } public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info(SERVICE: + new Date()); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Will be the the RUN-AT-paramter evaluated by Tomcat 5.0x or by anybody else? Use an external scheduler like Quartz or Flux. Andrzej Jan Taramina Chaeron Corporation: Enterprise System Solutions http://www.chaeron.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
If you are running Linux or Unix check the syntax for the 'nice' command. [EMAIL PROTECTED] 12-27-2004 18:55 Frank W. Zammetti wrote: It's interesting, Craig and I had an exchange about threads in servlet containers last week... I can't find a link to the thread unfortunately. Anyway, the basic idea behind that don't spawn your own threads inside a servlet container admonishment is based more on the fact that it's quite easy to screw up doing so, more than it has to do with virtually anything else. You want the servlet container to manager resources for you, and you lose that by spawning your own threads. The container isn't aware of the threads, so it can't control them for things like graceful shutdowns or simply trying to control resource utilization. Many people, including me, tend to ignore that warning when the situation warrants it, but you have to be extra-careful. For instance, you don't under any circumstances want to hold on to references to response, request or session objects because you don't manage them. You also, unless you really have a need and know what your doing, want to spawn threads to handle requests at all. Any threads you do spawn in a container should tend to be independent units of execution. If your use case fits that description, you can get away with it relatively safely. That being said, spawning things like daemon threads for low-level behind-the-scenes type processing is generally OK, so long as you are careful (i.e., be sure no runaway processing can occur, make sure it will shut down gracefully, etc). You might be able to use something like that in this case, you'll have to decide. If your using Struts, you can spawn the thread from a plug-in, as I've done in the past, but there are non-Struts equivalents (worse comes to worse, just do it in a servlet.init()). Do yourself a favor and make the thread processing functional independent of your app essentially, and even make it so it's not aware it's running in a servlet container. But again, caution is the key. If you make it a demon thread and set it's priority as low as you can and be sure to not hold on to a reference to it, I've found that works just fine under a number of app servers on a numeber of OSs. The bottom-line is that really that psuedo-rule is around because people tend to shoot themselves in the foot when using threads a bit too often, so better to advise against getting into a situation where you might do that. But, if your confident in your ability, and believe the use case really warrants it, you CAN do it, and relatively safely. Frank, I'm using threads and didn't know I was vulnerable. Here's how I've done it. I created a class that implements runnable and call its initialize method from a servlet init method at application startup. The initialize method creates a thread and sets a low priority for it. The run method sleeps the thread and wakes it every two minutes. A processing class contains the methods that queries the database (postgres). 1. Is this what you call a daemon thread? 2. Is this better done using cron? if so how do I ensure that it runs with a lower priority than my application code? Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Dennis Payne wrote: If you are running Linux or Unix check the syntax for the 'nice' command. [EMAIL PROTECTED] 12-27-2004 18:55 Frank W. Zammetti wrote: It's interesting, Craig and I had an exchange about threads in servlet containers last week... I can't find a link to the thread unfortunately. Anyway, the basic idea behind that don't spawn your own threads inside a servlet container admonishment is based more on the fact that it's quite easy to screw up doing so, more than it has to do with virtually anything else. You want the servlet container to manager resources for you, and you lose that by spawning your own threads. The container isn't aware of the threads, so it can't control them for things like graceful shutdowns or simply trying to control resource utilization. Many people, including me, tend to ignore that warning when the situation warrants it, but you have to be extra-careful. For instance, you don't under any circumstances want to hold on to references to response, request or session objects because you don't manage them. You also, unless you really have a need and know what your doing, want to spawn threads to handle requests at all. Any threads you do spawn in a container should tend to be independent units of execution. If your use case fits that description, you can get away with it relatively safely. That being said, spawning things like daemon threads for low-level behind-the-scenes type processing is generally OK, so long as you are careful (i.e., be sure no runaway processing can occur, make sure it will shut down gracefully, etc). You might be able to use something like that in this case, you'll have to decide. If your using Struts, you can spawn the thread from a plug-in, as I've done in the past, but there are non-Struts equivalents (worse comes to worse, just do it in a servlet.init()). Do yourself a favor and make the thread processing functional independent of your app essentially, and even make it so it's not aware it's running in a servlet container. But again, caution is the key. If you make it a demon thread and set it's priority as low as you can and be sure to not hold on to a reference to it, I've found that works just fine under a number of app servers on a numeber of OSs. The bottom-line is that really that psuedo-rule is around because people tend to shoot themselves in the foot when using threads a bit too often, so better to advise against getting into a situation where you might do that. But, if your confident in your ability, and believe the use case really warrants it, you CAN do it, and relatively safely. Frank, I'm using threads and didn't know I was vulnerable. Here's how I've done it. I created a class that implements runnable and call its initialize method from a servlet init method at application startup. The initialize method creates a thread and sets a low priority for it. The run method sleeps the thread and wakes it every two minutes. A processing class contains the methods that queries the database (postgres). 1. Is this what you call a daemon thread? 2. Is this better done using cron? if so how do I ensure that it runs with a lower priority than my application code? Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Will do, thanks Dennis. Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Dennis Payne wrote: Frank, I'm using threads and didn't know I was vulnerable. I'm not sure vulnerable is really the right word, but I'll go with it :) Here's how I've done it. I created a class that implements runnable and call its initialize method from a servlet init method at application startup. The initialize method creates a thread and sets a low priority for it. Roughly what I do too, except that my class extends Thread and I kick it off from a Struts plug-in. Same effect though. The run method sleeps the thread and wakes it every two minutes. A processing class contains the methods that queries the database (postgres). Same here. I think I wake my threads every minute though. 1. Is this what you call a daemon thread? Nope. If you take a peak at the javadocs for the Thread class, you'll see a method setDaemon(boolean). This marks a thread as a daemon thread. The difference, if I remember correctly, is that the JVM won't shut down until all remaining threads are daemon threads. Threfore, if you spawn a normal thread, you can hold up the JVM from shutting down properly. This is in fact the situation I had... My Tomcat instance could never be properly shut down because the threads I had spawned where not daemon threads. Marking them as such solved that problem. To the best of my knowledge, being a daemon thread doesn't implicitly say anything about a threads priority. I think you could have a daemon thread set at high priority if you wanted. I suspect most daemon threads are bumped to a lower priority though, as I do. 2. Is this better done using cron? if so how do I ensure that it runs with a lower priority than my application code? Phil This is a matter of opinion, and there are some reasonable arguments for both points of view. My personal opinion is that if you have some periodic process that is going to need portions of your system, whether it's resources available in the container or shared code, as you do, then a low-priority daemon thread spawned at application startup is a good approach, assuming you write it carefully and solidly. For instance, in my case, my daemon threads do some record aging in the database, so to me it makes sense to share the same connection pool as the application itself. I also use a number of classes and functions that are part of the webapp itself, and I don't like the idea of duplicating the code for a cron job to use (sure, could just be a matter of setting up a classpath to those classes, but it's an extra dependency, and that doesn't thrill me). But, if these tasks were volatile in any way, or they had to run independently of the app itself no matter what, the cron job approach would probably be preferable. As for ensuring it runs at a lower priority than your application code, when running via cron, that's an answer I can't give you. I'm frankly a Unix newbie, more or less, so someone else out there would be better suited to answer that. I think you'd have to have it run at a lower priority than your app server, and I'm sure there's switches to set priority of jobs, but I don't know them. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
The minimum thread priority is 1, maximum is 10 and medium or normal is 5. See: http://java.sun.com/j2se/1.4.2/docs/api/constant-values.html#java.lang.Thread.NORM_PRIORITY You can set a good neighbor poilicy with MIN_PRIORITY. Hunter on Servlets covers this with a daemon servlet. Jack On Tue, 28 Dec 2004 11:49:13 -0500, Frank W. Zammetti [EMAIL PROTECTED] wrote: Dennis Payne wrote: Frank, I'm using threads and didn't know I was vulnerable. I'm not sure vulnerable is really the right word, but I'll go with it :) Here's how I've done it. I created a class that implements runnable and call its initialize method from a servlet init method at application startup. The initialize method creates a thread and sets a low priority for it. Roughly what I do too, except that my class extends Thread and I kick it off from a Struts plug-in. Same effect though. The run method sleeps the thread and wakes it every two minutes. A processing class contains the methods that queries the database (postgres). Same here. I think I wake my threads every minute though. 1. Is this what you call a daemon thread? Nope. If you take a peak at the javadocs for the Thread class, you'll see a method setDaemon(boolean). This marks a thread as a daemon thread. The difference, if I remember correctly, is that the JVM won't shut down until all remaining threads are daemon threads. Threfore, if you spawn a normal thread, you can hold up the JVM from shutting down properly. This is in fact the situation I had... My Tomcat instance could never be properly shut down because the threads I had spawned where not daemon threads. Marking them as such solved that problem. To the best of my knowledge, being a daemon thread doesn't implicitly say anything about a threads priority. I think you could have a daemon thread set at high priority if you wanted. I suspect most daemon threads are bumped to a lower priority though, as I do. 2. Is this better done using cron? if so how do I ensure that it runs with a lower priority than my application code? Phil This is a matter of opinion, and there are some reasonable arguments for both points of view. My personal opinion is that if you have some periodic process that is going to need portions of your system, whether it's resources available in the container or shared code, as you do, then a low-priority daemon thread spawned at application startup is a good approach, assuming you write it carefully and solidly. For instance, in my case, my daemon threads do some record aging in the database, so to me it makes sense to share the same connection pool as the application itself. I also use a number of classes and functions that are part of the webapp itself, and I don't like the idea of duplicating the code for a cron job to use (sure, could just be a matter of setting up a classpath to those classes, but it's an extra dependency, and that doesn't thrill me). But, if these tasks were volatile in any way, or they had to run independently of the app itself no matter what, the cron job approach would probably be preferable. As for ensuring it runs at a lower priority than your application code, when running via cron, that's an answer I can't give you. I'm frankly a Unix newbie, more or less, so someone else out there would be better suited to answer that. I think you'd have to have it run at a lower priority than your app server, and I'm sure there's switches to set priority of jobs, but I don't know them. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --- This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Frank W. Zammetti wrote: Dennis Payne wrote: Frank, I'm using threads and didn't know I was vulnerable. I'm not sure vulnerable is really the right word, but I'll go with it :) Here's how I've done it. I created a class that implements runnable and call its initialize method from a servlet init method at application startup. The initialize method creates a thread and sets a low priority for it. Roughly what I do too, except that my class extends Thread and I kick it off from a Struts plug-in. Same effect though. The run method sleeps the thread and wakes it every two minutes. A processing class contains the methods that queries the database (postgres). Same here. I think I wake my threads every minute though. 1. Is this what you call a daemon thread? Nope. If you take a peak at the javadocs for the Thread class, you'll see a method setDaemon(boolean). This marks a thread as a daemon thread. The difference, if I remember correctly, is that the JVM won't shut down until all remaining threads are daemon threads. Threfore, if you spawn a normal thread, you can hold up the JVM from shutting down properly. This is in fact the situation I had... My Tomcat instance could never be properly shut down because the threads I had spawned where not daemon threads. Marking them as such solved that problem. To the best of my knowledge, being a daemon thread doesn't implicitly say anything about a threads priority. I think you could have a daemon thread set at high priority if you wanted. I suspect most daemon threads are bumped to a lower priority though, as I do. 2. Is this better done using cron? if so how do I ensure that it runs with a lower priority than my application code? Phil This is a matter of opinion, and there are some reasonable arguments for both points of view. My personal opinion is that if you have some periodic process that is going to need portions of your system, whether it's resources available in the container or shared code, as you do, then a low-priority daemon thread spawned at application startup is a good approach, assuming you write it carefully and solidly. For instance, in my case, my daemon threads do some record aging in the database, so to me it makes sense to share the same connection pool as the application itself. I also use a number of classes and functions that are part of the webapp itself, and I don't like the idea of duplicating the code for a cron job to use (sure, could just be a matter of setting up a classpath to those classes, but it's an extra dependency, and that doesn't thrill me). But, if these tasks were volatile in any way, or they had to run independently of the app itself no matter what, the cron job approach would probably be preferable. As for ensuring it runs at a lower priority than your application code, when running via cron, that's an answer I can't give you. I'm frankly a Unix newbie, more or less, so someone else out there would be better suited to answer that. I think you'd have to have it run at a lower priority than your app server, and I'm sure there's switches to set priority of jobs, but I don't know them. Frank, I also am doing record aging. I want to move records older than two minutes to a centralized server for processing. Think of it as multiple data collection servers and a centralized data processing server. I'm thinking that the daemon to schedule queries against the data collection servers should execute on the centralized server. I'm wonder if this form of light weight replication is a good practice. Does anyone have some insite on this? Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
I think what you describe is probably more properly implemented as some sort of queueing system. Something along the lines of setting up a queue on each data collection server that lazily updates the central server (there's other ways to structure it of course). Otherwise, I myself would tend towards a push model, since that's really more in line with how most web development is done. So, have the data collection servers push the records to the central server instead, whether queues are involved or not. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com phil campaigne wrote: Frank W. Zammetti wrote: Dennis Payne wrote: Frank, I'm using threads and didn't know I was vulnerable. I'm not sure vulnerable is really the right word, but I'll go with it :) Here's how I've done it. I created a class that implements runnable and call its initialize method from a servlet init method at application startup. The initialize method creates a thread and sets a low priority for it. Roughly what I do too, except that my class extends Thread and I kick it off from a Struts plug-in. Same effect though. The run method sleeps the thread and wakes it every two minutes. A processing class contains the methods that queries the database (postgres). Same here. I think I wake my threads every minute though. 1. Is this what you call a daemon thread? Nope. If you take a peak at the javadocs for the Thread class, you'll see a method setDaemon(boolean). This marks a thread as a daemon thread. The difference, if I remember correctly, is that the JVM won't shut down until all remaining threads are daemon threads. Threfore, if you spawn a normal thread, you can hold up the JVM from shutting down properly. This is in fact the situation I had... My Tomcat instance could never be properly shut down because the threads I had spawned where not daemon threads. Marking them as such solved that problem. To the best of my knowledge, being a daemon thread doesn't implicitly say anything about a threads priority. I think you could have a daemon thread set at high priority if you wanted. I suspect most daemon threads are bumped to a lower priority though, as I do. 2. Is this better done using cron? if so how do I ensure that it runs with a lower priority than my application code? Phil This is a matter of opinion, and there are some reasonable arguments for both points of view. My personal opinion is that if you have some periodic process that is going to need portions of your system, whether it's resources available in the container or shared code, as you do, then a low-priority daemon thread spawned at application startup is a good approach, assuming you write it carefully and solidly. For instance, in my case, my daemon threads do some record aging in the database, so to me it makes sense to share the same connection pool as the application itself. I also use a number of classes and functions that are part of the webapp itself, and I don't like the idea of duplicating the code for a cron job to use (sure, could just be a matter of setting up a classpath to those classes, but it's an extra dependency, and that doesn't thrill me). But, if these tasks were volatile in any way, or they had to run independently of the app itself no matter what, the cron job approach would probably be preferable. As for ensuring it runs at a lower priority than your application code, when running via cron, that's an answer I can't give you. I'm frankly a Unix newbie, more or less, so someone else out there would be better suited to answer that. I think you'd have to have it run at a lower priority than your app server, and I'm sure there's switches to set priority of jobs, but I don't know them. Frank, I also am doing record aging. I want to move records older than two minutes to a centralized server for processing. Think of it as multiple data collection servers and a centralized data processing server. I'm thinking that the daemon to schedule queries against the data collection servers should execute on the centralized server. I'm wonder if this form of light weight replication is a good practice. Does anyone have some insite on this? Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Frank W. Zammetti wrote: I think what you describe is probably more properly implemented as some sort of queueing system. Something along the lines of setting up a queue on each data collection server that lazily updates the central server (there's other ways to structure it of course). Otherwise, I myself would tend towards a push model, since that's really more in line with how most web development is done. So, have the data collection servers push the records to the central server instead, whether queues are involved or not. Frank, Jack, Thanks for your thoughtful answers. I have what I need to get started. Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Jukka Uusisalo wrote: Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] All, I am currrently using threads so I'd like to know if there is a way to set priorities so that an os scheduled job that hits my database won't take precedence over my application http requests. How do you control the priority when the data access task is a separate appolication? Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Frank W. Zammetti wrote: It's interesting, Craig and I had an exchange about threads in servlet containers last week... I can't find a link to the thread unfortunately. Anyway, the basic idea behind that don't spawn your own threads inside a servlet container admonishment is based more on the fact that it's quite easy to screw up doing so, more than it has to do with virtually anything else. You want the servlet container to manager resources for you, and you lose that by spawning your own threads. The container isn't aware of the threads, so it can't control them for things like graceful shutdowns or simply trying to control resource utilization. Many people, including me, tend to ignore that warning when the situation warrants it, but you have to be extra-careful. For instance, you don't under any circumstances want to hold on to references to response, request or session objects because you don't manage them. You also, unless you really have a need and know what your doing, want to spawn threads to handle requests at all. Any threads you do spawn in a container should tend to be independent units of execution. If your use case fits that description, you can get away with it relatively safely. That being said, spawning things like daemon threads for low-level behind-the-scenes type processing is generally OK, so long as you are careful (i.e., be sure no runaway processing can occur, make sure it will shut down gracefully, etc). You might be able to use something like that in this case, you'll have to decide. If your using Struts, you can spawn the thread from a plug-in, as I've done in the past, but there are non-Struts equivalents (worse comes to worse, just do it in a servlet.init()). Do yourself a favor and make the thread processing functional independent of your app essentially, and even make it so it's not aware it's running in a servlet container. But again, caution is the key. If you make it a demon thread and set it's priority as low as you can and be sure to not hold on to a reference to it, I've found that works just fine under a number of app servers on a numeber of OSs. The bottom-line is that really that psuedo-rule is around because people tend to shoot themselves in the foot when using threads a bit too often, so better to advise against getting into a situation where you might do that. But, if your confident in your ability, and believe the use case really warrants it, you CAN do it, and relatively safely. Frank, I'm using threads and didn't know I was vulnerable. Here's how I've done it. I created a class that implements runnable and call its initialize method from a servlet init method at application startup. The initialize method creates a thread and sets a low priority for it. The run method sleeps the thread and wakes it every two minutes. A processing class contains the methods that queries the database (postgres). 1. Is this what you call a daemon thread? 2. Is this better done using cron? if so how do I ensure that it runs with a lower priority than my application code? Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Use java.util.Timer and java.util.TimerTask. Create a Timer object. Timer timer = new Timer(). Then create a TimerTask object. SomeTask task = new SomeTasK(). private class SomeTask extends TimerTask { public void run() { // do stuff } } Schedule the task: timer.schedule(task, 10, 400). Wallah! I do this all the time. You have to know what you are doing. If you do, then do it. This is what the apps like Quartz do anyway. This is just lightweight. Jack -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --- This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
+1. you aren't being clear the only reason I can think you have an application wishing to talk to a servlet is that you are then going on to request info from the servlet from a remote machine across the net?? .. in that case and most others you should have your application polling the servlet itself in a thread. you'll need to explain your scenario if this is inaccurate, i.e if the Java App is in fact also a web app. JAVA APPLICATION || TOMCAT + SERVLET || INTERNET || REMOTE MACHINE - POLL 30s - REQUEST INFO --- RESPONSE -- RESPONSE -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:03 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Hello, Shilpa, With Wade, I wonder what you want. Apparently you have a client making and order and being informed about the status of the order. You say you have to develop a client application which looks to the database. Since this is a Tomcat list, that would seem to be a server application?Maybe by client application you mean a server application to help clients? If you are using a web, browser, based application, then you have to wait for the client to check with you rather than send the status to the remote client. Blah, blah, blah. The point, I guess, is that you really need to say in more detail what you are doing. What does your client look like? Can you create a rich client? Etc. Jack -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --- This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Why are you writing a servlet for this? If the application does not use any of the services confined to the Servlet API and Tomcat, just write a stand-alone application and setup up a cron job to run it. Seems like overkill to me. On Tue, 21 Dec 2004 16:28:49 -, Allistair Crossley [EMAIL PROTECTED] wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
I agree. Also You could write a standalone java class which does nothing but makes a http call to your Servlet. This class can be scheduled to run as a task every 30 minutes or so. pandu From: Allistair Crossley [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Date: Tue, 21 Dec 2004 16:28:49 - no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Laba diena. Dkojame, kad mums parate. Js atsista inut isaugota ms duomen bazje. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
My application has to use the connection pooling of Tomcat to talk to the database... and all my Database access classes are deployed om Tomcat...so if i just write a java standalone command line program, can i access those connection pooling classes... -Original Message- From: Billy Talton [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:41 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Why are you writing a servlet for this? If the application does not use any of the services confined to the Servlet API and Tomcat, just write a stand-alone application and setup up a cron job to run it. Seems like overkill to me. On Tue, 21 Dec 2004 16:28:49 -, Allistair Crossley [EMAIL PROTECTED] wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
of course you can ... look up http://jakarta.apache.org/commons/dbcp/ and commons-pool or your database's driver may even have an implementation that supports pooling that you can instantiate directly with the javax.sql or java.sql api. cron(30s) -- socket call -- your app (ServerSocket) -- spawn some new handler thread call database (dbcp e.g) -- get reply call client via xmlrpc get reply call database delete handler thread or put back into a pool ServerSocket wait -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:41 To: Tomcat Users List; Billy Talton Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 My application has to use the connection pooling of Tomcat to talk to the database... and all my Database access classes are deployed om Tomcat...so if i just write a java standalone command line program, can i access those connection pooling classes... -Original Message- From: Billy Talton [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:41 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Why are you writing a servlet for this? If the application does not use any of the services confined to the Servlet API and Tomcat, just write a stand-alone application and setup up a cron job to run it. Seems like overkill to me. On Tue, 21 Dec 2004 16:28:49 -, Allistair Crossley [EMAIL PROTECTED] wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
myself and ben have suggested the most appropriate methods for doing this. Ben mentions WGET http://www.gnu.org/software/wget/wget.html which can be added to a *basic* script hooked up to a cron with an interval of whatever you like. you really ought to get rid of threads and thread sleeps inside web application code. Allistair. -Original Message- From: Jorge Sopena [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 17:15 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Use cron in Unix/Linux or task scheduler in Windows. [EMAIL PROTECTED] 12-21-2004 08:44 Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
External scripts really are the best answer for this. It is not possible to 'PUSH' information like this without a dedicated client! [EMAIL PROTECTED] 12-21-2004 10:14 Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... Jorge. Allistair Crossley wrote: myself and ben have suggested the most appropriate methods for doing this. Ben mentions WGET http://www.gnu.org/software/wget/wget.html which can be added to a *basic* script hooked up to a cron with an interval of whatever you like. you really ought to get rid of threads and thread sleeps inside web application code. Allistair. -Original Message- From: Jorge Sopena [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 17:15 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- == Jorge Sopena Torres SIDSA (Semiconductores Investigación y Diseño, S.A.) Parque Tecnológico de Madrid c/ Torres Quevedo, nº 1 28760 TRES CANTOS (Madrid) (SPAIN) Phone : +34 91 803 5052 Fax:+34 91 803 9557 e-mail: [EMAIL PROTECTED] URL: http://www.sidsa.com ==
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
I would say it should be avoided at all if possible using threads. Since as we know in case of threads, there is not much management you can do. Also in my experience i have seen it is very easy for them to get out of control . So if there are any other alternatives, They should be explored first before threads. I am not sure if Tomcat supports MBeans, But I remeber in JBOss, you could create MBeans and schedule them in the container. Pandu From: Jorge Sopena [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Date: Tue, 21 Dec 2004 18:58:23 +0100 Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... Jorge. Allistair Crossley wrote: myself and ben have suggested the most appropriate methods for doing this. Ben mentions WGET http://www.gnu.org/software/wget/wget.html which can be added to a *basic* script hooked up to a cron with an interval of whatever you like. you really ought to get rid of threads and thread sleeps inside web application code. Allistair. -Original Message- From: Jorge Sopena [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 17:15 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- == Jorge Sopena Torres SIDSA (Semiconductores Investigación y Diseño, S.A.) Parque Tecnológico de Madrid c/ Torres Quevedo, nº 1 28760 TRES CANTOS (Madrid) (SPAIN) Phone : +34 91 803 5052 Fax:+34 91 803 9557 e-mail: [EMAIL PROTECTED] URL: http://www.sidsa.com == - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
Check out QuartzScheduler from Open Symphony it's easy to configure within Tomcat. Fredrik -Original Message- From: pandu yelamanchili [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 9:58 AM To: [EMAIL PROTECTED] Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 I would say it should be avoided at all if possible using threads. Since as we know in case of threads, there is not much management you can do. Also in my experience i have seen it is very easy for them to get out of control . So if there are any other alternatives, They should be explored first before threads. I am not sure if Tomcat supports MBeans, But I remeber in JBOss, you could create MBeans and schedule them in the container. Pandu From: Jorge Sopena [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Date: Tue, 21 Dec 2004 18:58:23 +0100 Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... Jorge. Allistair Crossley wrote: myself and ben have suggested the most appropriate methods for doing this. Ben mentions WGET http://www.gnu.org/software/wget/wget.html which can be added to a *basic* script hooked up to a cron with an interval of whatever you like. you really ought to get rid of threads and thread sleeps inside web application code. Allistair. -Original Message- From: Jorge Sopena [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 17:15 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- == Jorge Sopena Torres SIDSA (Semiconductores Investigación y Diseño, S.A.) Parque Tecnológico de Madrid c/ Torres Quevedo, nº 1 28760 TRES CANTOS (Madrid) (SPAIN) Phone : +34 91 803 5052 Fax:+34 91 803 9557 e-mail: [EMAIL PROTECTED] URL: http://www.sidsa.com == - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
You may user a scheduler to schedule your tasks to run every 30 minutes. http://www.theserverside.com/blogs/printfriendly.tss?id=QuartzSchedulerInJ2E E http://www.quartzscheduler.org/quartz/. Peiyun -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
You may use a scheduler to schedule your tasks to run every 30 minutes. http://www.theserverside.com/blogs/printfriendly.tss?id=QuartzSchedulerInJ2E E http://www.quartzscheduler.org/quartz/. Peiyun -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: December 21, 2004 11:41 AM To: Tomcat Users List; Billy Talton Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 My application has to use the connection pooling of Tomcat to talk to the database... and all my Database access classes are deployed om Tomcat...so if i just write a java standalone command line program, can i access those connection pooling classes... -Original Message- From: Billy Talton [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:41 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Why are you writing a servlet for this? If the application does not use any of the services confined to the Servlet API and Tomcat, just write a stand-alone application and setup up a cron job to run it. Seems like overkill to me. On Tue, 21 Dec 2004 16:28:49 -, Allistair Crossley [EMAIL PROTECTED] wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
You may use a scheduler to schedule your tasks to run every 30 minutes. http://www.theserverside.com/blogs/printfriendly.tss?id=QuartzSchedulerInJ2E E http://www.quartzscheduler.org/quartz/. Peiyun -Original Message- From: Allistair Crossley [mailto:[EMAIL PROTECTED] Sent: December 21, 2004 12:21 PM To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 myself and ben have suggested the most appropriate methods for doing this. Ben mentions WGET http://www.gnu.org/software/wget/wget.html which can be added to a *basic* script hooked up to a cron with an interval of whatever you like. you really ought to get rid of threads and thread sleeps inside web application code. Allistair. -Original Message- From: Jorge Sopena [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 17:15 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
It is possible to create a servlet thread in the init() method. That thread sould stay alive and run something every thirty minutes. The issue of pushing information out to the user remins the same. The servlet and the thread cannot do that. On the other hand, it is possible to setup java script on the page to detect 30 minute intervals to pull a page from the server. It is an awful lot of work for so little a result... It is best just to put a java process into cron or task scheduler and have the user run the report when they want the info. [EMAIL PROTECTED] 12-21-2004 14:44 Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
I think I saw something like this, but not sure if it works: servlet servlet-nameServlet/servlet-name servlet-classServlet/servlet-class run-atcron expression?/run-at load-on-startup1/load-on-startup /servlet Peiyun -Original Message- From: Dennis Payne [mailto:[EMAIL PROTECTED] Sent: December 21, 2004 5:37 PM To: [EMAIL PROTECTED] Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 It is possible to create a servlet thread in the init() method. That thread sould stay alive and run something every thirty minutes. The issue of pushing information out to the user remins the same. The servlet and the thread cannot do that. On the other hand, it is possible to setup java script on the page to detect 30 minute intervals to pull a page from the server. It is an awful lot of work for so little a result... It is best just to put a java process into cron or task scheduler and have the user run the report when they want the info. [EMAIL PROTECTED] 12-21-2004 14:44 Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
At 05:37 PM 12/21/2004, you wrote: It is possible to create a servlet thread in the init() method. That thread sould stay alive and run something every thirty minutes. The issue of pushing information out to the user remins the same. The servlet and the thread cannot do that. On the other hand, it is possible to setup java script on the page to detect 30 minute intervals to pull a page from the server. It is an awful lot of work for so little a result... It is best just to put a java process into cron or task scheduler and have the user run the report when they want the info. [EMAIL PROTECTED] 12-21-2004 14:44 Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - We have used a cron job using a command-line text-only web browser like 'links' or 'Lynx' to execute scripts like this at intervals. Much easier solution! Cheers. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. http://www.sng.ecs.soton.ac.uk/mailscanner/ Configuration by Glenn Parsons dnsadmin-at-1bigthink.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
It's interesting, Craig and I had an exchange about threads in servlet containers last week... I can't find a link to the thread unfortunately. Anyway, the basic idea behind that don't spawn your own threads inside a servlet container admonishment is based more on the fact that it's quite easy to screw up doing so, more than it has to do with virtually anything else. You want the servlet container to manager resources for you, and you lose that by spawning your own threads. The container isn't aware of the threads, so it can't control them for things like graceful shutdowns or simply trying to control resource utilization. Many people, including me, tend to ignore that warning when the situation warrants it, but you have to be extra-careful. For instance, you don't under any circumstances want to hold on to references to response, request or session objects because you don't manage them. You also, unless you really have a need and know what your doing, want to spawn threads to handle requests at all. Any threads you do spawn in a container should tend to be independent units of execution. If your use case fits that description, you can get away with it relatively safely. That being said, spawning things like daemon threads for low-level behind-the-scenes type processing is generally OK, so long as you are careful (i.e., be sure no runaway processing can occur, make sure it will shut down gracefully, etc). You might be able to use something like that in this case, you'll have to decide. If your using Struts, you can spawn the thread from a plug-in, as I've done in the past, but there are non-Struts equivalents (worse comes to worse, just do it in a servlet.init()). Do yourself a favor and make the thread processing functional independent of your app essentially, and even make it so it's not aware it's running in a servlet container. But again, caution is the key. If you make it a demon thread and set it's priority as low as you can and be sure to not hold on to a reference to it, I've found that works just fine under a number of app servers on a numeber of OSs. The bottom-line is that really that psuedo-rule is around because people tend to shoot themselves in the foot when using threads a bit too often, so better to advise against getting into a situation where you might do that. But, if your confident in your ability, and believe the use case really warrants it, you CAN do it, and relatively safely. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com Dennis Payne wrote: It is possible to create a servlet thread in the init() method. That thread sould stay alive and run something every thirty minutes. The issue of pushing information out to the user remins the same. The servlet and the thread cannot do that. On the other hand, it is possible to setup java script on the page to detect 30 minute intervals to pull a page from the server. It is an awful lot of work for so little a result... It is best just to put a java process into cron or task scheduler and have the user run the report when they want the info. [EMAIL PROTECTED] 12-21-2004 14:44 Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
On Tue, Dec 21, 2004 at 03:37:26PM -0700, Dennis Payne wrote: : It is possible to create a servlet thread in the init() method. That : thread sould stay alive and run something every thirty minutes. Yes and no. ;) It's possible to use a servlet's init() method for this; but per the spec, containers are free to initialize a servlet class as many times as they see fit. Much safer to use a ContextListener in this case, as those are triggered only on app (context) startup and shutdown. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Your just lending weight to what I said... Don't play with threads in a servlet contain unless your really sure you have to and are really sure you can do it safely :) (I'm not sure I knew init() could be called more than once, certainly I didn't remember when I wrote that, so excellent point) -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com QM wrote: On Tue, Dec 21, 2004 at 03:37:26PM -0700, Dennis Payne wrote: : It is possible to create a servlet thread in the init() method. That : thread sould stay alive and run something every thirty minutes. Yes and no. ;) It's possible to use a servlet's init() method for this; but per the spec, containers are free to initialize a servlet class as many times as they see fit. Much safer to use a ContextListener in this case, as those are triggered only on app (context) startup and shutdown. -QM - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Have fun I hope this helps!!! It should. web-app id='/' servlet servlet-name='hello' servlet-class='test.HelloWorld' load-on-startup/ /servlet /web-app The value is a list of 24-hour times when the servlet should be automatically executed. To run the servlet every 6 hours, you could use: servlet servlet-name='test.HelloWorld' run-at0:00, 6:00, 12:00, 18:00/run-at /servlet Frank W. Zammetti wrote: Your just lending weight to what I said... Don't play with threads in a servlet contain unless your really sure you have to and are really sure you can do it safely :) (I'm not sure I knew init() could be called more than once, certainly I didn't remember when I wrote that, so excellent point) -- Dwayne A. Ghant Application Developer Temple University 215.204. [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
The alarm is configured as any other servlet, with the addition of the run-at tag. The following configuration runs the servlet every 15 minutes. If the hour is missing, e.g. :15 the service is run at the specified minute. 15 minute configuration servlet name='alarm' servlet-class='test.TestAlarm' run-at:00, :15, :30, :45/run-at /servlet Allistair Crossley wrote: +1. you aren't being clear the only reason I can think you have an application wishing to talk to a servlet is that you are then going on to request info from the servlet from a remote machine across the net?? .. in that case and most others you should have your application polling the servlet itself in a thread. you'll need to explain your scenario if this is inaccurate, i.e if the Java App is in fact also a web app. JAVA APPLICATION || TOMCAT + SERVLET || INTERNET || REMOTE MACHINE - POLL 30s - REQUEST INFO --- RESPONSE -- RESPONSE -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:03 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dwayne A. Ghant Application Developer Temple University 215.204. [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Wow! After reading all of that long thread I got the SDN Editorial Team newsletter in my inbox. It talks about REVISITING TIMERS WITH ENTERPRISE BEANS. The link they give is https://bpcatalog.dev.java.net/nonav/enterprise/timerservice/. This should at least give some idea of how to do it J2EE style. I'm not sure if this will work in Tomcat, but I suspect that it will. Daniel - Original Message - From: Dwayne Ghant [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 9:24 PM Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 The alarm is configured as any other servlet, with the addition of the run-at tag. The following configuration runs the servlet every 15 minutes. If the hour is missing, e.g. :15 the service is run at the specified minute. 15 minute configuration servlet name='alarm' servlet-class='test.TestAlarm' run-at:00, :15, :30, :45/run-at /servlet Allistair Crossley wrote: +1. you aren't being clear the only reason I can think you have an application wishing to talk to a servlet is that you are then going on to request info from the servlet from a remote machine across the net?? .. in that case and most others you should have your application polling the servlet itself in a thread. you'll need to explain your scenario if this is inaccurate, i.e if the Java App is in fact also a web app. JAVA APPLICATION || TOMCAT + SERVLET || INTERNET || REMOTE MACHINE - POLL 30s - REQUEST INFO --- RESPONSE -- RESPONSE -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:03 To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Dwayne A. Ghant Application Developer Temple University 215.204. [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to run servlet for every 30 minutes in Tomcat 4.1.30
Hi, create a task in your scheduler that calls an URL with your servlet. That's how we do background processes like sending newsletters etc. Maarteb -Oorspronkelijk bericht- Van: Dennis Payne [mailto:[EMAIL PROTECTED] Verzonden: Tuesday, December 21, 2004 11:37 PM Aan: [EMAIL PROTECTED] Onderwerp: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 It is possible to create a servlet thread in the init() method. That thread sould stay alive and run something every thirty minutes. The issue of pushing information out to the user remins the same. The servlet and the thread cannot do that. On the other hand, it is possible to setup java script on the page to detect 30 minute intervals to pull a page from the server. It is an awful lot of work for so little a result... It is best just to put a java process into cron or task scheduler and have the user run the report when they want the info. [EMAIL PROTECTED] 12-21-2004 14:44 Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
You can just use the messaging classes in COS. Jack On Tue, 21 Dec 2004 16:28:49 -, Allistair Crossley [EMAIL PROTECTED] wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --- This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
+1 Jack On Tue, 21 Dec 2004 10:40:59 -0600, Billy Talton [EMAIL PROTECTED] wrote: Why are you writing a servlet for this? If the application does not use any of the services confined to the Servlet API and Tomcat, just write a stand-alone application and setup up a cron job to run it. Seems like overkill to me. On Tue, 21 Dec 2004 16:28:49 -, Allistair Crossley [EMAIL PROTECTED] wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. -Original Message- From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED] Sent: 21 December 2004 16:14 To: Tomcat Users List Subject: RE: How to run servlet for every 30 minutes in Tomcat 4.1.30 Thanks for the reply... The application which i am trying to write is a standalone utility.. Client does not hit this servlet. Instead my application which is a servlet, will make some database calls-- and if the required data is present in the database, then that data is sent to the client via xmlrpc call and the response from the xmlrpc call is updated back into the dataabse. So we want this utility preferably servlet in our Tomcat container to be run every 30 minutes like a cron job, to do the database updates.. There are so many other classes deployed on Tomcat and i want to use those classes to write this servlet utility. This is the reason why chose to use servlet, but is there any configurable parameter to run servlet for every 30 minutes... -Original Message- From: Wade Chandler [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 21, 2004 11:03 AM To: Tomcat Users List Subject: Re: How to run servlet for every 30 minutes in Tomcat 4.1.30 Shilpa Nalgonda wrote: Hi, I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. I wanted to do this in a servlet, so is there any way that i could run this servlet automatically inside the Tomcat container, or is it configurable in servlet mapping? if so can someone please suggest me with examples... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Wellit's kind of not extremely clear what you are asking, but why does the servlet need to do anything except listen for a client which is threaded to do this every 30 minutes, in other words...why not have the servlet do what it naturally does...sit there and get hit by client requestsget the infoand send it back? I mean...the servlet can't push to the client unless you want to use something besides http, or unless you are using servlets on both ends and http servers on both ends. You could use keep alives I guess.I wouldn't thoughonly so many tcp/ip connections. Wade - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] FONT SIZE=1 FACE=VERDANA,ARIAL COLOR=BLUE --- QAS Ltd. Developers of QuickAddress Software a href=http://www.qas.com;www.qas.com/a Registered in England: No 2582055 Registered in Australia: No 082 851 474 --- /FONT - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --- This message may contain confidential and/or privileged information. If you are not the addressee or authorized to
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
Why don't you guys use something like Lea's multithreading queues? Jack On Tue, 21 Dec 2004 18:14:30 +0100, Jorge Sopena [EMAIL PROTECTED] wrote: Hi, I'm having a similar problem in my application. I've got several servlets called by the users. Every requets save some information in DB, that has to be sent to another server later and in a compress format. So I need sth similar toShilpa is asking, a process which runs every X minutes to recover the information and send it to the Server. My solution to this problem was to implement a ServletContextListener inside Tomcat. When Tomcat starts my application the contextInitialized method is called, and then a thread is started to do the task explained above. I use Thread.sleep(step) to wait for the next execution. I didn't find anyway to set a timer for a servlet, and I didn't like the option of creating an external script . Any other suggestions to solver this problem? Thanks Jorge Ben Souther wrote: On Tue, 2004-12-21 at 11:28, Allistair Crossley wrote: no, and I believe doing so it bad practice. use some OS controlled timer like cron to issue a HTTP call to your servlet. I once wrote a shell script that calls a http address on the local machine but cannot remember how ;) if you are using oracle then you can setup this timer thread inside the database itself. don't add a thread into your web application. I concur. It's certainly possible to write a treaded java object that fires a command every so often but there would be no point in making that object a servlet (servlets exist to answer client requests). It's also, IMHO, more aggravation than it's worth to manage your own daemon threads in a webapp. It would take all of 2 minutes to write a timer with crontab and wget that could call your servlet whenever you want. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- You can lead a horse to water but you cannot make it float on its back. ~Dakota Jack~ You can't wake a person who is pretending to be asleep. ~Native Proverb~ Each man is good in His sight. It is not necessary for eagles to be crows. ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ --- This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to run servlet for every 30 minutes in Tomcat 4.1.30
[OT]Threads and Servlets Question on the struts-user list. Jack On Tue, 21 Dec 2004 18:17:40 -0500, Frank W. Zammetti [EMAIL PROTECTED] wrote: It's interesting, Craig and I had an exchange about threads in servlet containers last week... I can't find a link to the thread unfortunately. Anyway, the basic idea behind that don't spawn your own threads inside a servlet container admonishment is based more on the fact that it's quite easy to screw up doing so, more than it has to do with virtually anything else. You want the servlet container to manager resources for you, and you lose that by spawning your own threads. The container isn't aware of the threads, so it can't control them for things like graceful shutdowns or simply trying to control resource utilization. Many people, including me, tend to ignore that warning when the situation warrants it, but you have to be extra-careful. For instance, you don't under any circumstances want to hold on to references to response, request or session objects because you don't manage them. You also, unless you really have a need and know what your doing, want to spawn threads to handle requests at all. Any threads you do spawn in a container should tend to be independent units of execution. If your use case fits that description, you can get away with it relatively safely. That being said, spawning things like daemon threads for low-level behind-the-scenes type processing is generally OK, so long as you are careful (i.e., be sure no runaway processing can occur, make sure it will shut down gracefully, etc). You might be able to use something like that in this case, you'll have to decide. If your using Struts, you can spawn the thread from a plug-in, as I've done in the past, but there are non-Struts equivalents (worse comes to worse, just do it in a servlet.init()). Do yourself a favor and make the thread processing functional independent of your app essentially, and even make it so it's not aware it's running in a servlet container. But again, caution is the key. If you make it a demon thread and set it's priority as low as you can and be sure to not hold on to a reference to it, I've found that works just fine under a number of app servers on a numeber of OSs. The bottom-line is that really that psuedo-rule is around because people tend to shoot themselves in the foot when using threads a bit too often, so better to advise against getting into a situation where you might do that. But, if your confident in your ability, and believe the use case really warrants it, you CAN do it, and relatively safely. -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com Dennis Payne wrote: It is possible to create a servlet thread in the init() method. That thread sould stay alive and run something every thirty minutes. The issue of pushing information out to the user remins the same. The servlet and the thread cannot do that. On the other hand, it is possible to setup java script on the page to detect 30 minute intervals to pull a page from the server. It is an awful lot of work for so little a result... It is best just to put a java process into cron or task scheduler and have the user run the report when they want the info. [EMAIL PROTECTED] 12-21-2004 14:44 Jorge Sopena wrote: Why is bad using own threads inside web application? Aren't all the servlet request actually a thread in Tomcat? I can't find a reason why it's so bad solution. I think that comes from J2EE specs. I do not remember is threads just forbidden but if you follow specs, you do not know and you do not have to know how application server uses threads and controls thread behaviour. If portability is issue for your application, it is better to not use threads. In that way, you manage to have a single and independent application. Maybe I don't know some thread behaviour in Tomcat... After all, I have use threads in web application with tomcat :) and I haven't have any problems or strange thread behaviour. Sometimes whole concurrent programming and syncronizing my own threads causes troubles but nothing due tomcat. Back to original question. [EMAIL PROTECTED] wrote: I am using Tomcat4.1.30 version. I have to develop a client application which looks in the database every 30 minutes, ApplicationContextListener + Timer + TimerTask to retrieve the status of an order and send the status to the remote client. Again waits for the The client's response and insert the repsonse back to the database. What is that remote client? Is actually another server and your application is client. If so, just add client code for server in TimerTask (http-, web service- or whatever client). - Jukka - - To