Saturday, November 8, 2014

Scheduling with EJB

There is an easier way to schedule a job with EJB.
What we need is the EJB implementation and most important is the action method to be run.

@Stateless(name="serviceLookupName", mappedName="serviceLookupName")
public MyEjbServiceImpl {

    @Override
    @Schedule(dayOfMonth = "*", hour = "00", minute = "01")
    public void myScheduledMethod() {
       
        // action to run

    }
}


The advantage of this EJB schedule is easy to implement,
as just need to add the @Schedule annotation to an EJB method.

But the disadvantage is the scheduled time is hard to change,
if user wishes to change the time for the scheduler to run,
the source code need to be changed, recompile, and deploy.

for more information about the scheduler, please refer the official page.


Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...