Kế hoạch: IoT Receiver Service Feature
1. Hiện trạng
- 3 JMS listeners xử lý tất cả messages từ ControlServer.
- Concurrency hợp lý: gameplay/health = 1-50, log = 1-1.
- Slack notification cho disconnect và camera errors.
- Error code 81 tự động end game.
CraneMachineCheckStatusBatchConfigpolling status.
2. Vấn đề đã biết
| # | Vấn đề | Mức độ |
|---|---|---|
| 1 | DISCONNECTED_BY_APPLICATION Slack notification bị comment out |
Medium |
| 2 | endGameSuccess trong error-81 path có broad catch Exception — có thể nuốt lỗi quan trọng |
Medium |
| 3 | Không có idempotency cho log messages (duplicate possible khi redelivery) | Low |
| 4 | QUERY_GAME_RESULT_REPORT trong gameplay listener — chưa rõ use case và test coverage |
Low |
3. Kế hoạch cải tiến
Phase 1: Bug fixes
- Task 1-1: Review và quyết định về
DISCONNECTED_BY_APPLICATIONSlack notification (uncomment hoặc document lý do bỏ) - Task 1-2: Narrow exception handling trong error-81 path (không dùng broad
catch Exception)
Phase 2: Observability
- Task 2-1: Thêm metrics: messages processed per queue, error rate, processing latency
- Task 2-2: Log macIp không tìm thấy với warn level (hiện là silent UNKNOWN)
Phase 3: Testing
- Task 3-1: Test gameplay events: START_GAME → room updated → WS broadcast
- Task 3-2: Test health check: DISCONNECTED → DB updated → Slack sent
- Task 3-3: Test error code 81 → auto end game
4. Rủi ro
| Rủi ro | Ảnh hưởng | Biện pháp |
|---|---|---|
| Message burst from many machines | Queue lag → game events delayed | Scale consumers (1-50 là max, check if enough) |
IGameService slow → listener blocked |
Gameplay lag | IGameService performance profiling |
| Slack rate limit | Alert dropped | Deduplicate alerts, Slack queue |
| ControlServer restart → message flood | DB write spike | health-check queue 1-1 log cẩn thận |