Task 1-1: Review DISCONNECTED_BY_APPLICATION Slack Notification
Phase: 1 - Bug fixes Priority: Medium Module:
receiver-serviceDepends on: Không có Reference: docs/BountyHunter-Backend/details/feature-receiver-service/SPEC.md
Background
Trong JMSReceiverLogMachineListener, case DISCONNECTED_BY_APPLICATION có Slack notification bị comment out:
// slackNotificationService.notifySlackMachineDisconnectBySystem(machineHistoryLogModel.getMachineMac());
Không rõ lý do comment — có thể intentional (quá noisy) hoặc unintentional (bug).
Tasks
DI Note:
JMSReceiverLogMachineListenerđã injectSlackNotificationService(hoặc tương đương) cho các case khác — không cần thêm injection. Nếu chọn throttle-based alert, có thể cần injectRedisTemplateđể track disconnect count per time window.
File: receiver-service/jms/JMSReceiverLogMachineListener.java
-
[ ] Kiểm tra git blame / commit message để tìm lý do comment:
git log -S "notifySlackMachineDisconnectBySystem" -- receiver-service/ git blame receiver-service/src/main/java/com/figpop/jms/JMSReceiverLogMachineListener.java -
[ ] Quyết định dựa trên git history:
- Nếu intentional (quá noisy khi system restart): thêm comment giải thích rõ ràng:
// Intentionally suppressed: DISCONNECTED_BY_APPLICATION fires frequently during // normal system restarts. Consider throttle-based alert (e.g. > 5 disconnects/min). // slackNotificationService.notifySlackMachineDisconnectBySystem(machineHistoryLogModel.getMachineMac()); -
Nếu unintentional: uncomment và test rằng Slack notification được gửi đúng:
slackNotificationService.notifySlackMachineDisconnectBySystem( machineHistoryLogModel.getMachineMac() ); -
[ ] Nếu intentional: cân nhắc throttle-based alert thay thế (1 alert per machine per 5 phút):
- Track disconnect count trong Redis:
INCR receiver:disconnect:{machineMac}với TTL 5 phút - Chỉ alert khi count vượt threshold
Verification / Acceptance Criteria
- [ ] Comment code được xử lý: hoặc uncommented + tested, hoặc có comment giải thích lý do suppress
- [ ] Không còn commented-out code không có explanation
- [ ] Nếu uncommented: Slack notification gửi đúng khi
DISCONNECTED_BY_APPLICATIONevent xảy ra - [ ] Nếu throttled: alert chỉ gửi khi disconnect rate vượt threshold (không spam mỗi restart)
Files to Modify
receiver-service/src/main/java/com/figpop/jms/JMSReceiverLogMachineListener.java