Slackbot
09/09/2023, 3:19 PMJohnny Haugen Sørgård
09/10/2023, 1:03 AMimport io.micronaut.scheduling.annotation.Scheduled
import jakarta.inject.Singleton
@Slf4j
@CompileStatic
@Singleton
class MicronautJobService {
@Scheduled(fixedDelay = '10s')
void serviceMethodTenSeconds() {
<http://log.info|log.info>('serviceMethodTenSeconds')
}
@Scheduled(cron = '2 */1 * * * *')
void serviceMethodCronEveryMinute() {
<http://log.info|log.info>('serviceMethodCronEveryMinute')
}
}
In comparison here's a Spring variation I got working:
import org.springframework.scheduling.annotation.Scheduled
@Slf4j
@CompileStatic
class SpringJobService {
static lazyInit = false
@Scheduled(fixedDelay = 2000L)
void serviceMethodTwoSeconds() {
<http://log.info|log.info>('serviceMethodTwoSeconds')
}
@Scheduled(cron = '0 */1 * * * *')
void serviceMethodCronEveryMinute() {
<http://log.info|log.info>('serviceMethodCronEveryMinute')
}
}Johnny Haugen Sørgård
09/10/2023, 1:05 AMimport org.springframework.scheduling.annotation.EnableScheduling
@EnableScheduling
@CompileStatic
class Application extends GrailsAutoConfiguration {Mark N.
09/11/2023, 5:33 AMMark N.
09/11/2023, 5:44 AMMark N.
09/11/2023, 5:46 AM