Getting JBoss Scheduler working
When using the
It took me a while to get the objectName right. If your not using
Instead I'd recommend going into the JMX console of the running server and searching for it manually, listed under 'jboss.j2ee' for the name you've specified AND type=ManagementInterface.
As well as defining the @Service, you'll also need to define the @Management.
Then create a file the appropriate place
e.g. MyEar.ear/MyEjb.jar/META-INF/myscheduler-service.xml:
Good luck.
@Service
annotation together with the scheduler has given me no end of trouble so I'd like to share my working configuration.It took me a while to get the objectName right. If your not using
@Service(objectName='name')
but instead using @Service(name='name')
then the final object name is not the same as what they imply at EJB Extensions Help.Instead I'd recommend going into the JMX console of the running server and searching for it manually, listed under 'jboss.j2ee' for the name you've specified AND type=ManagementInterface.
As well as defining the @Service, you'll also need to define the @Management.
@Management(SampleServiceMBean.class) @Service(name = SampleServiceMBean.SERVICE_NAME) public class SampleServiceMBean implements SampleService { public final static String SERVICE_NAME = "SampleServiceMBean"; public void process(ObjectName name, Date date) { log.info("process {} {}", name, date); }
Then create a file the appropriate place
e.g. MyEar.ear/MyEjb.jar/META-INF/myscheduler-service.xml:
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=MyScheduler"> <attribute name="StartAtStartup">true</attribute> <attribute name="SchedulableMBean">jboss.j2ee:ear=MyEar.ear,jar=MyEjb.jar,name=SampleServiceMBean,service=EJB3,type=ManagementInterface</attribute> <attribute name="SchedulableMBeanMethod">process( SCHEDULER_NAME, DATE )</attribute> <attribute name="InitialStartDate">NOW</attribute> <attribute name="SchedulePeriod">60000</attribute> <attribute name="InitialRepetitions">10</attribute> <attribute name="FixedRate">true</attribute> <depends> <mbean code="javax.management.timer.Timer" name="jboss:service=Timer"/> </depends> </mbean> </server>The parameter list threw me off for a while. If you get errors like
java.lang.IllegalArgumentException: Unable to find operation processPending(javax.management.ObjectName,java.util.Date)
, the the key is the argument list (obviously).Good luck.
Thank you! Very helpful!
ReplyDelete