2018년 2월 4일 일요일

Quartz 라이브러리를 이용한 스케줄링

▮ spring-framework의 어플리케이션 설정파일에 아래 설정 추가

<bean id=jobDetailBean class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name=jobClass value="net.oopscode.ScheduleJobBean"></property>
</bean>

<bean id=cronTriggerBean class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name=jobDetail ref=jobDetailBean/>
    <property name=cronExpression value="0/10 * * * * ?"/>
</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
       <list>
          <ref bean="cronTriggerBean"/>
       </list>
    </property>
</bean>

▮ 스케줄링할 클래스 생성
public class ScheduleJobBean extends QuartzJobBean {
    @Override
    protected void executeInternal(JobExecutionContext arg0) throws JobExecutionException {
        System.out.println(System.currentTimeMillis());
    }
}

댓글 없음:

댓글 쓰기

Creating CRC32 Hex string

public String getCRC32HexaString(String paramString) throws Exception  {   byte bytes[] = paramString.getBytes(DEFAULT_CHARSET);   Che...