Communication — Dữ liệu & bảng đọc/ghi
Góc nhìn database cho Communication: artifact nằm ở nhiều kho (SQL / Azure Table / Blob / Queue). Quy ước: 📖 READ, ✏️ WRITE (insert/update).
Khái niệm liên quan từ domain khác
| Khái niệm | Là gì | Vai trò trong Communication | Domain sở hữu |
|---|---|---|---|
| EntityEvent | Sự kiện "có gì đó vừa đổi". | Đầu vào đường event-derived → sinh NotificationJob. | Platform |
| NotificationSetting / NotificationOption | Cấu hình loại notification theo BU + subscriber. | Bước Scheduler đánh giá: loại này có bật không, gửi cho ai. | Org/Settings |
| MessageTemplate | Mẫu nội dung có placeholder. | Generator render template. | Messaging |
| ContactGroup | Nhóm người nhận. | Campaign nhắm nhóm (MessageJob_ContactGroup). | Attendee/Contact |
| Account / Attendee / Employee | Người nhận. | Resolve recipients (customer/staff). | Account/Staff |
| ReportSubscription / ReportSubscriber | Đăng ký báo cáo định kỳ. | Nguồn của đường report (xem Report Subscription). | Reporting |
| EmployeeCompliance / Invoice | Nguồn dữ liệu reminder. | Trigger provider tính ngày hết hạn / đến hạn. | Staff / Finance |
Bản đồ kho lưu trữ
| Kho | Artifact | Ghi chú |
|---|---|---|
| Azure SQL | NotificationScheduler, NotificationOption, NotificationSetting(+_Account/_Employee), MessageTemplate, MessagingJob, MessagingJobScheduler, MessageJob_ContactGroup, ReportSubscription, ReportSubscriptionScheduler, ReportSubscriber, ReminderStateLog, NotificationBanner | Hàng đợi & cấu hình. |
| Azure Table | NotificationJob, OutgoingMessage, UserMessage, AutomationJob | Bản ghi nhiều dòng, phân vùng theo entity/người nhận. |
| Azure Blob | container messaging-job (payload campaign/report) | Nội dung lớn; SQL chỉ giữ tên blob. |
| Azure Queue | hàng đợi giữa các worker | Vận chuyển việc. |
| Azure SQL (automation) | AutomationScheduler | Điều phối due-work reminder/report (xem Automation). |
💡
NotificationJob/OutgoingMessage/UserMessagelà Azure Table, không phải bảng SQL — đó là lý do chúng dùng PartitionKey/RowKey thay vì PK/FK.
Bảng dữ liệu trong từng luồng
Luồng gửi (Scheduler → Generator → Distributor)
| Bước | Bảng | Tác dụng |
|---|---|---|
| Scheduler | NotificationScheduler, MessagingJob 📖 READ; NotificationSetting/NotificationOption 📖 READ | Lấy việc Ready; đánh giá settings. |
| Generator | MessageTemplate 📖 READ; NotificationJob 📖 READ | Render + resolve recipients. |
| Generator (output) | UserMessage ✏️ WRITE; OutgoingMessage ✏️ WRITE | Sinh tin in-app + tin gửi ra (mỗi người nhận/kênh). |
| Distributor | OutgoingMessage ✏️ UPDATE (claim → Sending → Sent) | "Claim trước khi gửi". |
| Webhook & Tracker | OutgoingMessage ✏️ UPDATE (delivered/opened/bounce) | Cập nhật trạng thái từ provider. |
Luồng automation/reminder
| Bước | Bảng | Tác dụng |
|---|---|---|
| Tạo việc | AutomationScheduler ✏️ WRITE (ensure/deactivate) | Lịch việc đến hạn (SchedulerKey UNIQUE). |
| Đến hạn | AutomationScheduler 📖 READ + claim (Version) | Worker chốt quyền xử lý. |
| Trace mirror | AutomationJob ✏️ WRITE (Azure Table) | Bản sao trace mỏng. |
| State log | ReminderStateLog ✏️ WRITE | Ghi trạng thái reminder. |
| Giao hàng | NotificationScheduler ✏️ WRITE (qua dispatch guard) | Bắc cầu sang pipeline gửi. |
Luồng campaign
| Bước | Bảng | Tác dụng |
|---|---|---|
| Tạo campaign | MessagingJob ✏️ WRITE; blob messaging-job ✏️ WRITE; MessageJob_ContactGroup ✏️ WRITE | Điều phối payload lớn + nhóm người nhận. |
| Lên lịch | MessagingJobScheduler, NotificationScheduler ✏️ WRITE | Đưa vào pipeline gửi. |
Liên quan
- Kiến trúc — pipeline gửi & key policy.
- Lịch sử & quan sát — audit & trace.