定义一个Job类
public class OffsetsQuartz {
public void jobQuartz() {
String[] clusterAliass = SystemConfigUtils.getPropertyArray("kafka.eagle.zk.cluster.alias", ",");
for (String clusterAlias : clusterAliass) {
execute(clusterAlias);
}
}
}
<bean id="offsetsSchedule" class="org.smartloli.kafka.eagle.web.quartz.OffsetsQuartz" />
<!-- Method for configuring scheduling specific execution. -->
<!-- task1 -->
<bean id="offsetsDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="offsetsSchedule" />
<property name="targetMethod" value="jobQuartz" />
<property name="concurrent" value="false" />
</bean>
<!-- Configure the trigger time for scheduling execution. -->
<bean id="offsetsTrigger"
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="offsetsDetail" />
<property name="cronExpression">
<!-- per 5min 每5分钟重启一次-->
<value>0 0/5 * * * ?</value>
</property>
</bean>
<!-- 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<!-- All scheduling lists. -->
<ref local="offsetsTrigger" />
</list>
</property>
</bean>