Search code examples
javaejbwebspherescheduled-tasks

@Schedule annotation and timeout in EJB bean


What happens if I have @Scheduled task which runs every 5 seconds and sometimes it takes more than 5 seconds to complete this task? EJB container knows how to deal in such scenario or I need to care it by myself? Thank you.

P.S. My EJB bean annotated by @Startup and @Singleton, and I run it on Websphere 8.0


Solution

  • I think you are good because you bean is annotated with @Singleton. EJB beans are synchronized unless you explicitly mark methods with @Asynchronous. So if a cron execution(a thread) is in progress then other cron run(another thread) will have to wait for the first one to finish.