Author |
Message |
29/04/2022 11:28:48
|
kklasen
Power User
Joined: 19/11/2020 08:33:30
Messages: 66
Offline
|
Hello,
I want to make a triggered event on server side. All 24 hours it should check some entries on Database. I tried with TimerTask class but it never triggers.
So, I found some Demos for triggering but they only wait some seconds und not a whole day.
Is it not possible to use TimerTask on server side? Or is there a Demo with a long long long Trigger.
thanks for the help!
Kind regards
Klas
|
|
|
29/04/2022 12:00:05
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5516
Offline
|
Hi,
the "enemy" you are fighting with is the session-timeout! ;-)
THis is configured in web.xml:
Code:
...
<session-config>
...
<session-timeout>60</session-timeout>
...
</session-config>
(in minutes)
In more complex situations there are also other session timeouts involved (proxy, single sign on, ...), so things can be more complicated in addition.
So better set the timer to "every 30 minutes" and then manage the actual counting of the 24 hours on server-side.
Kind regards! Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
04/05/2022 11:56:54
|
kklasen
Power User
Joined: 19/11/2020 08:33:30
Messages: 66
Offline
|
Hello,
A question if I use this method:
Code:
private void timerTask24() {
String nameOfTable = "tbl_training_gebucht" , column_name = "TrainBookID", sCustData , whereName = "Aktiv";
sCustData = 1 +" : " +1;
TimerTask repeatedTask = new TimerTask() {
public void run() {
// Statusbar.outputMessage("Task performed on " + new Date()+" "+ Thread.currentThread().getName());
LoadUpdateDBTrain(nameOfTable, column_name, sCustData, whereName);
}
};
Timer timer = new Timer("Timer 24h");
long delay = 1000L;
// long period = 1000L * 60L * 60L * 24L;
long period = 1000L * 60L ;
timer.scheduleAtFixedRate(repeatedTask, delay, period);
}
And put the method name in the constructor, should it not work? I am a little bit confused.
Kind regards
Klas
|
|
|
04/05/2022 12:10:01
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5516
Offline
|
Hi Klas,
now I am confused, too. ;-)
When I was talking about "timer" then I was talking about the TIMER-component of CaptainCasa. This is like a "virutal button" which presses itself automatically every x milliseconds. (x defines in DURATION attribute).
The session needs to be kept alive by requests from the client side. (Like a user that is constantly interacting...)
In the demo workplace you find examples: General > Asynchrnous Processing > Timer
Hope, this clarifies confusion! (?)
Kind regards, Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
04/05/2022 13:20:01
|
kklasen
Power User
Joined: 19/11/2020 08:33:30
Messages: 66
Offline
|
Hello,
ah okey!
looks very cool, I give it a try.
Kind regards
Klas
|
|
|
|