Spring의 Annotaion 기반 스케쥴링 방법.
■ 개요
method 단위 스케쥴링 가능
실행주기는 fixedDelay, fixedRate, cron 3가지 속성 존재함
@Scheduled Annotaion을 부여한 method는 void return, 입력인자가 없음에 유의
중복수행을 막기위해 @Configurable를 사용하지 말아야함
Spring 설정XML에 아래 내용이 추가되어야 함.
1 2 | < task:annotation-driven > </ task:annotation-driven > |
■ 사용예
1 2 3 4 5 | @Scheduled (fixedDelay= 5000 , initialDelay = 1000 ) public void doSomething() { // 이전 호출이 완료된 시점부터 고정적으로 5초마다 수행됨. // 최초 수행시 에는 1초 딜레타임이 발생함. } |
1 2 3 4 5 | @Scheduled (fixedRate= 5000 ) public void doSomething() { // 연속적인 시작 시각의 간격으로 계산된 5초마다 수행됨. // * 이전 수행의 종료를 기다리지 않고 수행됨 } |
1 2 3 4 | @Scheduled (cron= "*/5 * * * * MON-FRI" ) public void doSomething() { // cron 표현식을 이용한 주기적 수행. } |
'IT > Spring' 카테고리의 다른 글
JSP에서 properties에 선언된 값 불러오기 (0) | 2017.02.14 |
---|---|
@PostConstruct and @PreDestroy (0) | 2015.08.19 |
Root Application Context와 Servlet Context (0) | 2015.08.18 |
WRITTEN BY
- Dukejin
If you don't walk today, you will have to run tomorrow. Try hard, Try hard!
,