티스토리 뷰
728x90
출처 : Chapter 19. Quartz 혹은 Timer 를 사용한 스케쥴링
DongHoReportBatch.java
package com.blueX.batch; import java.text.SimpleDateFormat; import java.util.Date; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.scheduling.quartz.QuartzJobBean; public class DongHoReportBatch extends QuartzJobBean { @Override protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { Date dt = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd, hh:mm:ss a"); System.out.println(sdf.format(dt).toString()); } public static void main(String[] args) throws Exception { String[] configLocation = new String[] { "file:WebContent/WEB-INF/blueX-servlet.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(configLocation); } }
blueX-servlet.xml
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" autowire="no"> <property name="triggers"> <list> <ref bean="dongHoReportTrigger" /> </list> </property> <property name="quartzProperties"> <props> <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop> <prop key="org.quartz.threadPool.threadCount">5</prop> <prop key="org.quartz.threadPool.threadPriority">4</prop> <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop> <prop key="org.quartz.jobStore.misfireThreshold">60000</prop> </props> </property> </bean> <bean id="dongHoReportTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <property name="jobDetail" ref="dongHoReportJob" /> <property name="startDelay" value="60000"/> <!-- 서버 시작후 1분후 첫 실행 --> <property name="repeatInterval" value="300000"/> <!-- 첫 실행 후 5분 마다 실행 --> </bean> <bean id="dongHoReportJob" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="com.blueX.batch.DongHoReportBatch" /> </bean>
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 서울오토살롱
- Linux
- 일본여행
- ble
- Delphi
- KOBA
- 튜닝쇼 2008
- 전예희
- BPI-M4
- ubuntu
- flex
- Delphi Tip
- Spring
- 송주경
- SAS
- 동경
- MySQL
- Xcode
- koba2010
- 지스타2007
- Spring MVC
- ffmpeg
- NDK
- android
- Java
- oracle
- sas2009
- JavaScript
- 레이싱모델 익스트림 포토 페스티벌
- Mac
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
글 보관함