开发者

How to configure JBoss/Quartz to run Spring job?

开发者 https://www.devze.com 2023-03-22 07:41 出处:网络
I\'m new to JBoss, having been using tomcat for years.I have a Spring 3.0.x application in which I need to run a job on a regular basis.In the past, I would simply create my job class as a regular POJ

I'm new to JBoss, having been using tomcat for years. I have a Spring 3.0.x application in which I need to run a job on a regular basis. In the past, I would simply create my job class as a regular POJO, and then create my job/trigger as Spring's CronTriggerBean passing a MethodInvokingJobDetailFactoryBean as my jobDetail.

Ex:

  <bean id="session.manage.UserSessionPurgeAction.trigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
            <property name="cronExpression" value="0 */5 * * * ? *" />
            <property name="jobDetail">
                    <bean class="org.springframework.scheduling.quart开发者_运维百科z.MethodInvokingJobDetailFactoryBean">
                      <property name="name"><idref bean="session.manage.UserSessionPurgeAction" /></property>
                      <property name="group" value="cleanup" />
                            <property name="targetObject" ref="session.manage.UserSessionPurgeAction" />
                            <property name="targetMethod" value="execute" />
                            <property name="concurrent" value="false" />
                    </bean>
            </property>
    </bean>

On this new project, the system architect has called for running the Spring application under JBoss 6. I know that JBoss has a quartz scheduler built in, so I am not sure how to package/declare my job such that it is using JBoss' scheduler as opposed to building it into the app as I have done in the past.

I've searched online, but cannot seem to find the necessary glue information that I need. I know that there is a @Schedule annotation in javax.ejb but is that all I need to add to my method? I would think/expect that I need additional configuration somewhere, but not sure where.

Can anyone point me in the right direction please?

Thanks,

Eric


If you really want to use the jboss one, I would try matching the schedulerName property passed to SchedulerFactoryBean with one of the bundled scheduler. The bundled scheduler can be retrieved via JNDI, it's under jndi name "Quartz" I think.

Have a look at org.springframework.scheduling.quartz.SchedulerFactoryBean#createScheduler, it tries to look up the scheduler in static SchedulerRepository first.

0

精彩评论

暂无评论...
验证码 换一张
取 消