About Timers¶
A timer in the Backendless custom business logic system is a block of code with some execution schedule. A timer itself does not need to perform any scheduling work, Backendless automatically calculates the time for the next execution step of the timer, allocates computing resources and runs the code. Consider the following timer implementation:
package com.backendless.ordermanagement.timers;
import com.backendless.servercode.annotation.BackendlessTimer;
import com.backendless.servercode.extension.TimerExtender;
@BackendlessTimer("{'startDate':1398186600000,'expire':1398878100000,'frequency':{'schedule':'daily','repeat':{'every':1}},'timername':'cool'}")
public class CoolTimer extends TimerExtender
{
@Override
public void execute( String appVersionId ) throws Exception
{
// add your custom logic here
}
}
A timer must follow the following guidelines:
- A timer implementation must be a public class which extends
com.backendless.servercode.extension.TimerExtender.
- A time must have the
@BackendlessTimer
annotation which defines timer's schedule and the name. - A timer must override the
execute
method from theTimerExtender
class. Any custom business logic must be in the method.