Announcement Announcement Module
Collapse
No announcement yet.
Best practice for keeping one Thread running Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best practice for keeping one Thread running

    Hi,

    I need to refactor/rewrite an application that crashes a lot.

    It basically uses a java.util.Time scheduleAtFixedRate() to launch a TimerTask, that pulls incoming messages from a webservice and do something if any.
    I suspect the timer 'crashes' if any run of TimeTask throws an exception, such that if any scheduled job crashes, it will not re-schedule a new one (?)


    The question is how do I best do it in spring (running in tomcat)?

    My initial thoughts are as follows:

    Start a singleton bean (worker) doing the pull work in a loop try/catch throwable;
    Make a Quartz job ref. the worker, that checks if the thread is dead; if so, restart it.

    Is there any standard way to do it?

    Any suggestion is highly appreciated,

    Regards,

  • #2
    Any idea/though?
    Is it completely bad idea I have there?

    Regards

    Comment

    Working...
    X