I am required to create a timer/schedule service in jboss (JEE6). The issue is, it gets deployed as jboss module. I know that following code works if deployed as EJB
@Schedule(hour="*/1", persistent=false)
but it doesnt work if deployed otherwise. Are there any recommendations or standard ways to create and use timers in jboss modules? I want to avoid core-java way of creating TimerTask.
jboss modules are created for sharing code across applications in an efficient way. For more refer here. Now, because modules are not deployed in EJB container; its not possible to use EJB scheduler here. The possible solution or way around for this in our case was to create an EJB which has dependency on these jboss modules whose methods will be invoked by schedulers.
for example,
@Singleton
@Startup
public class NotificationRecorderBean {
@Inject
private MyJbossModule myJbossModule;
@Schedule(hour="*/1", persistent=false)
public void execute() {
LOGGER.debug("Recording notification count");
myJbossModule.process();
}
}