@things-factory/scheduler 9.0.3 → 9.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,6 +5,115 @@
|
|
|
5
5
|
- 호출된 이벤트가 실패할 경우 정책에 따라서 일정 시간 이후 재시도 수행
|
|
6
6
|
- 스케줄러 처리의 부하를 분산하기 위해서 새롭게 설계된 구조로서 스케줄러는 데이터베이스 기반의 큐 구조를 사용하여 모든 스케줄 데이터를 관리
|
|
7
7
|
|
|
8
|
+
## 🚀 독창적인 기능들
|
|
9
|
+
|
|
10
|
+
### 1. 5차원 클라이언트 식별자 시스템
|
|
11
|
+
|
|
12
|
+
스케줄러는 단순한 UUID 기반 식별을 넘어서는 독창적인 5차원 클라이언트 식별 시스템을 사용합니다:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"client": {
|
|
17
|
+
"application": "data-collection-app",
|
|
18
|
+
"group": "domain-123",
|
|
19
|
+
"type": "data-set",
|
|
20
|
+
"key": "sensor-001",
|
|
21
|
+
"operation": "collect"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**주요 장점:**
|
|
27
|
+
|
|
28
|
+
- **비즈니스 컨텍스트 인식**: 식별자가 기술적 ID가 아닌 비즈니스 의미를 반영
|
|
29
|
+
- **중복 방지**: 5개 요소가 모두 일치할 때만 동일한 스케줄로 인식
|
|
30
|
+
- **자연스러운 조직화**: application → group → type → key → operation의 계층적 구조
|
|
31
|
+
- **유연한 필터링**: 클라이언트 속성의 조합으로 스케줄 필터링 가능
|
|
32
|
+
|
|
33
|
+
### 2. 혁신적인 스케줄 타입
|
|
34
|
+
|
|
35
|
+
#### delay-recur: 혁신적인 반복 패턴
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"type": "delay-recur",
|
|
40
|
+
"schedule": "30",
|
|
41
|
+
"timezone": "UTC"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- **간단한 반복**: 복잡한 cron 표현식 없이 30초 간격 반복
|
|
46
|
+
- **실시간 최적화**: 모니터링, 하트비트, 데이터 동기화에 완벽
|
|
47
|
+
- **리소스 효율성**: 전통적인 cron 기반 접근법보다 가벼움
|
|
48
|
+
|
|
49
|
+
#### 포괄적인 스케줄 타입 지원
|
|
50
|
+
|
|
51
|
+
- **now**: 즉시 실행
|
|
52
|
+
- **delay**: 일회성 지연 실행
|
|
53
|
+
- **date**: 특정 날짜/시간 실행
|
|
54
|
+
- **cron**: 전통적인 cron 기반 스케줄링
|
|
55
|
+
- **delay-recur**: 혁신적인 반복 패턴
|
|
56
|
+
|
|
57
|
+
### 3. 고급 실패 처리
|
|
58
|
+
|
|
59
|
+
#### retry_dlq: 하이브리드 실패 정책
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"failed_policy": "retry_dlq",
|
|
64
|
+
"retry_wait": 60,
|
|
65
|
+
"max_retry_count": 3
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**3단계 실패 처리:**
|
|
70
|
+
|
|
71
|
+
1. **즉시 재시도**: 지수 백오프를 통한 빠른 재시도
|
|
72
|
+
2. **최대 재시도**: 설정된 최대 시도 횟수까지
|
|
73
|
+
3. **Dead Letter Queue**: 실패한 작업을 DLQ로 이동하여 나중에 처리
|
|
74
|
+
|
|
75
|
+
**장점:**
|
|
76
|
+
|
|
77
|
+
- **시스템 안정성**: 무한 재시도 루프 방지
|
|
78
|
+
- **데이터 보존**: 실패 시에도 데이터 손실 없음
|
|
79
|
+
- **문제 진단**: DLQ를 통한 실패 원인 분석 가능
|
|
80
|
+
|
|
81
|
+
### 4. 히스토리 인식 스케줄링
|
|
82
|
+
|
|
83
|
+
#### history_check: 실행 히스토리 관리
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"history_check": true
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**기능:**
|
|
92
|
+
|
|
93
|
+
- **중복 방지**: 이미 완료된 작업의 재실행 방지
|
|
94
|
+
- **상태 기반 의사결정**: 실행 히스토리를 기반으로 한 스케줄링 결정
|
|
95
|
+
- **감사 추적**: 규정 준수 및 디버깅을 위한 완전한 실행 히스토리
|
|
96
|
+
|
|
97
|
+
### 5. 도메인 인식 콜백 시스템
|
|
98
|
+
|
|
99
|
+
#### 멀티 테넌트 지원
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"task": {
|
|
104
|
+
"connection": {
|
|
105
|
+
"host": "http://localhost:3000/domain/company/callback-schedule-for-dataset"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**장점:**
|
|
112
|
+
|
|
113
|
+
- **테넌트 격리**: 각 도메인의 스케줄이 독립적으로 처리
|
|
114
|
+
- **자동 URL 생성**: 도메인 컨텍스트가 콜백 URL에 자동 포함
|
|
115
|
+
- **보안**: 도메인 기반 접근 제어 및 데이터 격리
|
|
116
|
+
|
|
8
117
|
### 스케줄러의 주기적 처리에 대한 Diagram
|
|
9
118
|
|
|
10
119
|

|
|
@@ -34,11 +143,107 @@
|
|
|
34
143
|
- 스케줄러 서비스는 Restful 기반의 수평 확장이 가능한 스케줄러 서비스.
|
|
35
144
|
- MSA 기반의 어플리케이션 환경에서 기존 어플리케이션이 수행하는 스케줄링 모듈에 대해서, 별도의 스케줄링 서비스를 분리해서 제공하는 서비스를 제공합니다.
|
|
36
145
|
|
|
146
|
+
## 🎯 사용 사례 및 모범 사례
|
|
147
|
+
|
|
148
|
+
### 실시간 모니터링
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"name": "sensor-monitoring",
|
|
153
|
+
"client": {
|
|
154
|
+
"application": "iot-platform",
|
|
155
|
+
"group": "factory-001",
|
|
156
|
+
"type": "sensor",
|
|
157
|
+
"key": "temperature-sensor-01",
|
|
158
|
+
"operation": "monitor"
|
|
159
|
+
},
|
|
160
|
+
"type": "delay-recur",
|
|
161
|
+
"schedule": "30",
|
|
162
|
+
"timezone": "Asia/Seoul",
|
|
163
|
+
"task": {
|
|
164
|
+
"type": "rest",
|
|
165
|
+
"connection": {
|
|
166
|
+
"host": "http://localhost:3000/api/sensor/collect",
|
|
167
|
+
"headers": { "Content-Type": "application/json" }
|
|
168
|
+
},
|
|
169
|
+
"data": { "sensorId": "temp-001", "threshold": 25 },
|
|
170
|
+
"history_check": true,
|
|
171
|
+
"failed_policy": "retry_dlq",
|
|
172
|
+
"retry_wait": 60,
|
|
173
|
+
"max_retry_count": 3
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 데이터 동기화
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"name": "data-sync",
|
|
183
|
+
"client": {
|
|
184
|
+
"application": "erp-system",
|
|
185
|
+
"group": "company-abc",
|
|
186
|
+
"type": "inventory",
|
|
187
|
+
"key": "daily-sync",
|
|
188
|
+
"operation": "sync"
|
|
189
|
+
},
|
|
190
|
+
"type": "cron",
|
|
191
|
+
"schedule": "0 2 * * *",
|
|
192
|
+
"timezone": "Asia/Seoul",
|
|
193
|
+
"task": {
|
|
194
|
+
"type": "kafka",
|
|
195
|
+
"connection": {
|
|
196
|
+
"host": "localhost:9092",
|
|
197
|
+
"topic": "inventory-sync"
|
|
198
|
+
},
|
|
199
|
+
"data": { "syncType": "full", "timestamp": "2024-01-01T02:00:00Z" },
|
|
200
|
+
"history_check": true,
|
|
201
|
+
"failed_policy": "retry_dlq",
|
|
202
|
+
"retry_wait": 300,
|
|
203
|
+
"max_retry_count": 5
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 보고서 생성
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"name": "daily-report",
|
|
213
|
+
"client": {
|
|
214
|
+
"application": "analytics-platform",
|
|
215
|
+
"group": "marketing-team",
|
|
216
|
+
"type": "report",
|
|
217
|
+
"key": "daily-metrics",
|
|
218
|
+
"operation": "generate"
|
|
219
|
+
},
|
|
220
|
+
"type": "cron",
|
|
221
|
+
"schedule": "0 9 * * 1-5",
|
|
222
|
+
"timezone": "Asia/Seoul",
|
|
223
|
+
"task": {
|
|
224
|
+
"type": "rest",
|
|
225
|
+
"connection": {
|
|
226
|
+
"host": "http://localhost:3000/api/reports/generate",
|
|
227
|
+
"headers": { "Authorization": "Bearer ..." }
|
|
228
|
+
},
|
|
229
|
+
"data": { "reportType": "daily", "recipients": ["team@company.com"] },
|
|
230
|
+
"history_check": true,
|
|
231
|
+
"failed_policy": "retry",
|
|
232
|
+
"retry_wait": 1800,
|
|
233
|
+
"max_retry_count": 2
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
37
238
|
## 사용 가능한 용도
|
|
38
239
|
|
|
39
240
|
- 크론(cron) 기반의 스케줄잡(Schedule Job) 핸들러
|
|
40
241
|
- 특정한 날짜 혹은 특정한 주기로 실행되는 태스크 실행 엔진
|
|
41
242
|
- 특정한 이벤트를 등록 관리하고, 이벤트를 기반으로 특정 기능을 실행하거나 데이터를 전달하는 브로커
|
|
243
|
+
- **실시간 모니터링**: delay-recur를 사용한 짧은 간격의 연속 모니터링
|
|
244
|
+
- **데이터 동기화**: 시스템 간의 주기적 데이터 동기화
|
|
245
|
+
- **보고서 생성**: 자동화된 보고서 생성 및 배포
|
|
246
|
+
- **IoT 디바이스 관리**: IoT 디바이스 통신 및 데이터 수집 관리
|
|
42
247
|
|
|
43
248
|
### Schedule
|
|
44
249
|
|
|
@@ -119,7 +324,6 @@
|
|
|
119
324
|
```
|
|
120
325
|
|
|
121
326
|
- cron: cron format을 기반으로 스케줄이 동작합니다.
|
|
122
|
-
|
|
123
327
|
- 기본적인 5개 포맷을 사용합니다.
|
|
124
328
|
- 초 단위 스케줄리을 실행하기 위해서는 6개 시간 요소가 필요하면, 첫번째 요소가 초를 지정합니다.
|
|
125
329
|
|
|
@@ -183,3 +387,77 @@
|
|
|
183
387
|
}
|
|
184
388
|
}
|
|
185
389
|
```
|
|
390
|
+
|
|
391
|
+
## 🔧 고급 설정
|
|
392
|
+
|
|
393
|
+
### 재시도 정책
|
|
394
|
+
|
|
395
|
+
#### ignore
|
|
396
|
+
|
|
397
|
+
- 재시도 시도 없음
|
|
398
|
+
- 중요하지 않은 작업에 적합
|
|
399
|
+
|
|
400
|
+
#### retry
|
|
401
|
+
|
|
402
|
+
- 지수 백오프를 통한 단순 재시도
|
|
403
|
+
- 일시적 실패에 좋음
|
|
404
|
+
|
|
405
|
+
#### retry_dlq
|
|
406
|
+
|
|
407
|
+
- Dead Letter Queue 폴백을 통한 재시도
|
|
408
|
+
- 데이터 보존이 필요한 중요 작업에 최적
|
|
409
|
+
|
|
410
|
+
### 히스토리 체크 설정
|
|
411
|
+
|
|
412
|
+
#### true
|
|
413
|
+
|
|
414
|
+
- 중복 실행 방지
|
|
415
|
+
- 실행 히스토리 유지
|
|
416
|
+
- 데이터 수집 및 보고서에 적합
|
|
417
|
+
|
|
418
|
+
#### false
|
|
419
|
+
|
|
420
|
+
- 다중 실행 허용
|
|
421
|
+
- 히스토리 추적 없음
|
|
422
|
+
- 실시간 모니터링에 적합
|
|
423
|
+
|
|
424
|
+
### 타임존 고려사항
|
|
425
|
+
|
|
426
|
+
- **글로벌 배포**: 다중 타임존 지원
|
|
427
|
+
- **업무 시간**: 현지 업무 시간 기준 스케줄 실행
|
|
428
|
+
- **DST 처리**: 자동 일광절약시간 조정
|
|
429
|
+
|
|
430
|
+
## 🚀 성능 최적화
|
|
431
|
+
|
|
432
|
+
### 모범 사례
|
|
433
|
+
|
|
434
|
+
1. **짧은 간격에는 delay-recur 사용**: 빈번한 작업에 cron보다 효율적
|
|
435
|
+
2. **데이터 작업에는 history_check 구현**: 중복 데이터 처리 방지
|
|
436
|
+
3. **적절한 재시도 정책 구성**: 신뢰성과 성능의 균형
|
|
437
|
+
4. **타임존 인식 스케줄링 사용**: 정확한 실행 시간 보장
|
|
438
|
+
5. **DLQ 모니터링**: 정기적으로 실패한 작업 확인 및 처리
|
|
439
|
+
|
|
440
|
+
### 확장 고려사항
|
|
441
|
+
|
|
442
|
+
- **수평 확장**: 여러 스케줄러 인스턴스가 동시에 실행 가능
|
|
443
|
+
- **부하 분산**: 데이터베이스 기반 큐가 인스턴스 간 부하 분산
|
|
444
|
+
- **장애 복구 지원**: 인스턴스 다운 시 자동 장애 복구
|
|
445
|
+
- **리소스 관리**: 지능형 스케줄링을 통한 효율적인 리소스 활용
|
|
446
|
+
|
|
447
|
+
## 🔍 모니터링 및 문제 해결
|
|
448
|
+
|
|
449
|
+
### 모니터링해야 할 주요 지표
|
|
450
|
+
|
|
451
|
+
- **실행 성공률**: 성공적인 작업 실행 비율
|
|
452
|
+
- **재시도 빈도**: 작업당 재시도 횟수
|
|
453
|
+
- **DLQ 크기**: Dead Letter Queue의 작업 수
|
|
454
|
+
- **실행 시간**: 작업 완료 평균 시간
|
|
455
|
+
- **스케줄 정확도**: 예상 실행 시간과의 편차
|
|
456
|
+
|
|
457
|
+
### 일반적인 문제 및 해결책
|
|
458
|
+
|
|
459
|
+
1. **높은 재시도율**: 네트워크 연결성 및 대상 서비스 가용성 확인
|
|
460
|
+
2. **DLQ 오버플로우**: 실패한 작업 검토 및 근본 원인 수정
|
|
461
|
+
3. **실행 누락**: 타임존 설정 및 스케줄 표현식 확인
|
|
462
|
+
4. **성능 문제**: 빈번한 작업에는 delay-recur 사용 고려
|
|
463
|
+
5. **중복 실행**: 적절한 작업에 history_check 활성화
|
|
@@ -5,6 +5,115 @@
|
|
|
5
5
|
- If an invoked event fails, it retries after a certain period, as defined by the policy.
|
|
6
6
|
- To distribute the load of scheduler processing, a newly designed structure uses a database-based queue to manage all schedule data.
|
|
7
7
|
|
|
8
|
+
## 🚀 Unique Features
|
|
9
|
+
|
|
10
|
+
### 1. Five-Dimensional Client Identifier System
|
|
11
|
+
|
|
12
|
+
The scheduler uses a unique 5-dimensional client identification system that goes beyond simple UUID-based identification:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"client": {
|
|
17
|
+
"application": "data-collection-app",
|
|
18
|
+
"group": "domain-123",
|
|
19
|
+
"type": "data-set",
|
|
20
|
+
"key": "sensor-001",
|
|
21
|
+
"operation": "collect"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Key Benefits:**
|
|
27
|
+
|
|
28
|
+
- **Business Context Awareness**: Identifiers reflect business meaning rather than technical IDs
|
|
29
|
+
- **Duplicate Prevention**: Only schedules with all 5 elements matching are considered identical
|
|
30
|
+
- **Natural Organization**: Hierarchical organization from application → group → type → key → operation
|
|
31
|
+
- **Flexible Filtering**: Filter schedules by any combination of client properties
|
|
32
|
+
|
|
33
|
+
### 2. Innovative Schedule Types
|
|
34
|
+
|
|
35
|
+
#### delay-recur: Revolutionary Recurring Pattern
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"type": "delay-recur",
|
|
40
|
+
"schedule": "30",
|
|
41
|
+
"timezone": "UTC"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- **Simple Recurrence**: 30-second intervals without complex cron expressions
|
|
46
|
+
- **Real-time Optimization**: Perfect for monitoring, heartbeat, and data synchronization
|
|
47
|
+
- **Resource Efficiency**: Lightweight compared to traditional cron-based approaches
|
|
48
|
+
|
|
49
|
+
#### Comprehensive Schedule Type Support
|
|
50
|
+
|
|
51
|
+
- **now**: Immediate execution
|
|
52
|
+
- **delay**: One-time delayed execution
|
|
53
|
+
- **date**: Specific date/time execution
|
|
54
|
+
- **cron**: Traditional cron-based scheduling
|
|
55
|
+
- **delay-recur**: Innovative recurring pattern
|
|
56
|
+
|
|
57
|
+
### 3. Advanced Failure Handling
|
|
58
|
+
|
|
59
|
+
#### retry_dlq: Hybrid Failure Policy
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"failed_policy": "retry_dlq",
|
|
64
|
+
"retry_wait": 60,
|
|
65
|
+
"max_retry_count": 3
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Three-Stage Failure Handling:**
|
|
70
|
+
|
|
71
|
+
1. **Immediate Retry**: Quick retry with exponential backoff
|
|
72
|
+
2. **Maximum Retries**: Up to configured maximum attempts
|
|
73
|
+
3. **Dead Letter Queue**: Failed tasks moved to DLQ for later processing
|
|
74
|
+
|
|
75
|
+
**Benefits:**
|
|
76
|
+
|
|
77
|
+
- **System Stability**: Prevents infinite retry loops
|
|
78
|
+
- **Data Preservation**: No data loss even with failures
|
|
79
|
+
- **Problem Diagnosis**: DLQ enables failure analysis
|
|
80
|
+
|
|
81
|
+
### 4. History-Aware Scheduling
|
|
82
|
+
|
|
83
|
+
#### history_check: Execution History Management
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"history_check": true
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Features:**
|
|
92
|
+
|
|
93
|
+
- **Duplicate Prevention**: Avoids re-executing already completed tasks
|
|
94
|
+
- **State-Based Decisions**: Makes scheduling decisions based on execution history
|
|
95
|
+
- **Audit Trail**: Complete execution history for compliance and debugging
|
|
96
|
+
|
|
97
|
+
### 5. Domain-Aware Callback System
|
|
98
|
+
|
|
99
|
+
#### Multi-Tenant Support
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"task": {
|
|
104
|
+
"connection": {
|
|
105
|
+
"host": "http://localhost:3000/domain/company/callback-schedule-for-dataset"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Benefits:**
|
|
112
|
+
|
|
113
|
+
- **Tenant Isolation**: Each domain's schedules are processed independently
|
|
114
|
+
- **Automatic URL Generation**: Domain context automatically included in callback URLs
|
|
115
|
+
- **Security**: Domain-based access control and data isolation
|
|
116
|
+
|
|
8
117
|
### Diagram for Periodic Processing in the Scheduler
|
|
9
118
|
|
|
10
119
|

|
|
@@ -24,7 +133,7 @@
|
|
|
24
133
|

|
|
25
134
|
|
|
26
135
|
- The traditional application structure for processing scheduling jobs cannot function in a cloud-based horizontal scaling architecture.
|
|
27
|
-
- A separate scheduler service is needed. While there are many services for such tasks, there isn
|
|
136
|
+
- A separate scheduler service is needed. While there are many services for such tasks, there isn't a dedicated service solely for the role of scheduling.
|
|
28
137
|
- A scalable service that can be horizontally expanded in a cloud environment is required.
|
|
29
138
|
|
|
30
139
|
## Service Overview
|
|
@@ -34,11 +143,107 @@
|
|
|
34
143
|
- Scheduler service is a horizontally scalable scheduling service based on RESTful architecture.
|
|
35
144
|
- It provides a service that separates scheduling modules from existing applications in MSA-based environments.
|
|
36
145
|
|
|
146
|
+
## 🎯 Use Cases and Best Practices
|
|
147
|
+
|
|
148
|
+
### Real-Time Monitoring
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"name": "sensor-monitoring",
|
|
153
|
+
"client": {
|
|
154
|
+
"application": "iot-platform",
|
|
155
|
+
"group": "factory-001",
|
|
156
|
+
"type": "sensor",
|
|
157
|
+
"key": "temperature-sensor-01",
|
|
158
|
+
"operation": "monitor"
|
|
159
|
+
},
|
|
160
|
+
"type": "delay-recur",
|
|
161
|
+
"schedule": "30",
|
|
162
|
+
"timezone": "Asia/Seoul",
|
|
163
|
+
"task": {
|
|
164
|
+
"type": "rest",
|
|
165
|
+
"connection": {
|
|
166
|
+
"host": "http://localhost:3000/api/sensor/collect",
|
|
167
|
+
"headers": { "Content-Type": "application/json" }
|
|
168
|
+
},
|
|
169
|
+
"data": { "sensorId": "temp-001", "threshold": 25 },
|
|
170
|
+
"history_check": true,
|
|
171
|
+
"failed_policy": "retry_dlq",
|
|
172
|
+
"retry_wait": 60,
|
|
173
|
+
"max_retry_count": 3
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Data Synchronization
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"name": "data-sync",
|
|
183
|
+
"client": {
|
|
184
|
+
"application": "erp-system",
|
|
185
|
+
"group": "company-abc",
|
|
186
|
+
"type": "inventory",
|
|
187
|
+
"key": "daily-sync",
|
|
188
|
+
"operation": "sync"
|
|
189
|
+
},
|
|
190
|
+
"type": "cron",
|
|
191
|
+
"schedule": "0 2 * * *",
|
|
192
|
+
"timezone": "Asia/Seoul",
|
|
193
|
+
"task": {
|
|
194
|
+
"type": "kafka",
|
|
195
|
+
"connection": {
|
|
196
|
+
"host": "localhost:9092",
|
|
197
|
+
"topic": "inventory-sync"
|
|
198
|
+
},
|
|
199
|
+
"data": { "syncType": "full", "timestamp": "2024-01-01T02:00:00Z" },
|
|
200
|
+
"history_check": true,
|
|
201
|
+
"failed_policy": "retry_dlq",
|
|
202
|
+
"retry_wait": 300,
|
|
203
|
+
"max_retry_count": 5
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Report Generation
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"name": "daily-report",
|
|
213
|
+
"client": {
|
|
214
|
+
"application": "analytics-platform",
|
|
215
|
+
"group": "marketing-team",
|
|
216
|
+
"type": "report",
|
|
217
|
+
"key": "daily-metrics",
|
|
218
|
+
"operation": "generate"
|
|
219
|
+
},
|
|
220
|
+
"type": "cron",
|
|
221
|
+
"schedule": "0 9 * * 1-5",
|
|
222
|
+
"timezone": "Asia/Seoul",
|
|
223
|
+
"task": {
|
|
224
|
+
"type": "rest",
|
|
225
|
+
"connection": {
|
|
226
|
+
"host": "http://localhost:3000/api/reports/generate",
|
|
227
|
+
"headers": { "Authorization": "Bearer ..." }
|
|
228
|
+
},
|
|
229
|
+
"data": { "reportType": "daily", "recipients": ["team@company.com"] },
|
|
230
|
+
"history_check": true,
|
|
231
|
+
"failed_policy": "retry",
|
|
232
|
+
"retry_wait": 1800,
|
|
233
|
+
"max_retry_count": 2
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
37
238
|
## Usable Scenarios
|
|
38
239
|
|
|
39
240
|
- **Cron-Based Schedule Job Handlers**: For processing tasks at specific intervals.
|
|
40
241
|
- **Task Execution Engines**: For executing tasks on specific dates or at specific intervals.
|
|
41
242
|
- **Event-Driven Task Handlers**: For registering and managing events, and executing specific tasks or transferring data based on those events.
|
|
243
|
+
- **Real-Time Monitoring**: For continuous monitoring with short intervals using delay-recur.
|
|
244
|
+
- **Data Synchronization**: For periodic data synchronization between systems.
|
|
245
|
+
- **Report Generation**: For automated report generation and distribution.
|
|
246
|
+
- **IoT Device Management**: For managing IoT device communication and data collection.
|
|
42
247
|
|
|
43
248
|
### Schedule
|
|
44
249
|
|
|
@@ -119,7 +324,6 @@ An example of the format for registering a schedule is as follows:
|
|
|
119
324
|
```
|
|
120
325
|
|
|
121
326
|
- **cron**: Operates based on the cron format.
|
|
122
|
-
|
|
123
327
|
- Uses the basic five-element format.
|
|
124
328
|
- For second-level schedules, a six-element format is required, where the first element specifies seconds.
|
|
125
329
|
|
|
@@ -184,3 +388,77 @@ An example of the format for registering a schedule is as follows:
|
|
|
184
388
|
}
|
|
185
389
|
}
|
|
186
390
|
```
|
|
391
|
+
|
|
392
|
+
## 🔧 Advanced Configuration
|
|
393
|
+
|
|
394
|
+
### Retry Policies
|
|
395
|
+
|
|
396
|
+
#### ignore
|
|
397
|
+
|
|
398
|
+
- No retry attempts
|
|
399
|
+
- Suitable for non-critical tasks
|
|
400
|
+
|
|
401
|
+
#### retry
|
|
402
|
+
|
|
403
|
+
- Simple retry with exponential backoff
|
|
404
|
+
- Good for transient failures
|
|
405
|
+
|
|
406
|
+
#### retry_dlq
|
|
407
|
+
|
|
408
|
+
- Retry with Dead Letter Queue fallback
|
|
409
|
+
- Best for critical tasks requiring data preservation
|
|
410
|
+
|
|
411
|
+
### History Check Configuration
|
|
412
|
+
|
|
413
|
+
#### true
|
|
414
|
+
|
|
415
|
+
- Prevents duplicate execution
|
|
416
|
+
- Maintains execution history
|
|
417
|
+
- Suitable for data collection and reporting
|
|
418
|
+
|
|
419
|
+
#### false
|
|
420
|
+
|
|
421
|
+
- Allows multiple executions
|
|
422
|
+
- No history tracking
|
|
423
|
+
- Suitable for real-time monitoring
|
|
424
|
+
|
|
425
|
+
### Timezone Considerations
|
|
426
|
+
|
|
427
|
+
- **Global Deployment**: Support for multiple timezones
|
|
428
|
+
- **Business Hours**: Schedule execution based on local business hours
|
|
429
|
+
- **DST Handling**: Automatic daylight saving time adjustments
|
|
430
|
+
|
|
431
|
+
## 🚀 Performance Optimization
|
|
432
|
+
|
|
433
|
+
### Best Practices
|
|
434
|
+
|
|
435
|
+
1. **Use delay-recur for short intervals**: More efficient than cron for frequent tasks
|
|
436
|
+
2. **Implement history_check for data tasks**: Prevents duplicate data processing
|
|
437
|
+
3. **Configure appropriate retry policies**: Balance between reliability and performance
|
|
438
|
+
4. **Use timezone-aware scheduling**: Ensure accurate execution times
|
|
439
|
+
5. **Monitor DLQ**: Regularly check and process failed tasks
|
|
440
|
+
|
|
441
|
+
### Scaling Considerations
|
|
442
|
+
|
|
443
|
+
- **Horizontal Scaling**: Multiple scheduler instances can run simultaneously
|
|
444
|
+
- **Load Distribution**: Database-based queue distributes load across instances
|
|
445
|
+
- **Failover Support**: Automatic failover when instances go down
|
|
446
|
+
- **Resource Management**: Efficient resource utilization through intelligent scheduling
|
|
447
|
+
|
|
448
|
+
## 🔍 Monitoring and Troubleshooting
|
|
449
|
+
|
|
450
|
+
### Key Metrics to Monitor
|
|
451
|
+
|
|
452
|
+
- **Execution Success Rate**: Percentage of successful task executions
|
|
453
|
+
- **Retry Frequency**: Number of retries per task
|
|
454
|
+
- **DLQ Size**: Number of tasks in Dead Letter Queue
|
|
455
|
+
- **Execution Time**: Average time for task completion
|
|
456
|
+
- **Schedule Accuracy**: Deviation from expected execution times
|
|
457
|
+
|
|
458
|
+
### Common Issues and Solutions
|
|
459
|
+
|
|
460
|
+
1. **High Retry Rate**: Check network connectivity and target service availability
|
|
461
|
+
2. **DLQ Overflow**: Review failed tasks and fix underlying issues
|
|
462
|
+
3. **Missed Executions**: Verify timezone settings and schedule expressions
|
|
463
|
+
4. **Performance Issues**: Consider using delay-recur for frequent tasks
|
|
464
|
+
5. **Duplicate Executions**: Enable history_check for appropriate tasks
|