1
I have a non-web project and I will turn it into a web project using Spring MVC.
Today in my method static main
of my main class, I create it here:
Exec.principalTimer = new Timer();
Exec.principalTimer.scheduleAtFixedRate(new PrincipalTimerTask(), Exec.delay, Exec.interval);
The class PrincipalTimerTask
is the type TimerTask
.
How I create this Timer in Spring already in the implementation of the project, without having to call any url and let it run there, as if it were a service if I don’t have one public static main
in the Web container?
I can implement the Webapplicationinitializer interface and create the Timer already within the onStartup method.
Here’s where I got the idea http://joshlong.com/jl/blogPost/simplified_web_configuration_with_spring.html
Web applications have a different status handling of console applications, with windows or services. I think you will need, in addition to the web application, a service that keeps calling something by URL or other means at fixed intervals. The technical name for this is Cron Job.
– Oralista de Sistemas
You may not use Quartz (http://www.quartz-scheduler.org/)?
– NilsonUehara
I’ll note here, the boring is like "one more framework"... ahhah
– Andre