Reputation: 91
I have a server side built on the top of JBOSS 7 AS.
I have a need to run a batch process every 24 hours to perform some operations on the DB. Whilst it is easy to implement the service, I am wondering what the best is to launch is... Any examples available?
In my old JBOSS days, I would have kicked this off through a boostrap servlet.
Cheers.
Upvotes: 2
Views: 881
Reputation: 17846
Use an EJB3.1 Timer: http://javahowto.blogspot.be/2010/04/ejb-31-timer-simple-example.html
@Stateless
public class BatchLauncher {
@Schedule(hour = "12", minute = "0")
private void checkInventory() {
By default, JBoss 7 will scan your war/ear for ejb3 annotated classes. For @Stateless beans, JBoss will create a singleton and make it accessible via JNDI.
Inside the singletons, JBoss 7 will find the @Schedule annotation and schedule the method invocation using the schedule.
Upvotes: 1