This message was deleted.
# questions
s
This message was deleted.
j
I did some testing a while back on, but that was grails 5. Here's a test that I got working:
Copy code
import 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:
Copy code
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')
    }

}
For Spring scheduling I had to configure Application class like this:
Copy code
import org.springframework.scheduling.annotation.EnableScheduling

@EnableScheduling
@CompileStatic
class Application extends GrailsAutoConfiguration {
m
Thanks for the input. Can't get it working in Grails 6, but I'll work around it for now.
I'm not on top of this. Should this be the micronaut @scheduled annotation or the spring one ? As I can see both could be used in grails 6
Actually - when using the spring @EnableScheduling in my Application class and the spring @Scheduled annotation in my JobService it works. So I had is mixed around.