MS-24/feat(order): Add weekly failed Shippingbo orders report and 7-day sync window
Summary
This MR introduces a monitoring and alerting system for orders that fail to synchronize with Shippingbo, along with reliability improvements to the sync process itself.
Problem Statement
Previously, orders that failed to sync with Shippingbo would be retried indefinitely every 15 minutes, potentially causing:
- Unnecessary API calls for orders that will never succeed
- No visibility into orders stuck in failed sync state
- Potential performance degradation from processing a growing backlog of unsynced orders
Solution
1. 7-Day Sync Window
Orders are now only eligible for Shippingbo sync if they were created within the last 7 days. This prevents:
- Infinite retry loops for problematic orders
- Processing of stale orders that may no longer be relevant
2. Weekly Email Report
A new scheduled job runs every Sunday at 6 PM (configurable via cron) and sends an email report containing:
- Total count of failed orders
- Order details: ID, creation date, client name, client email, items count, days pending
- Client information is enriched via the User Service API
3. Configurable Settings
All report parameters are externalized to Config Server with environment-specific values.
New Files
| File | Description |
|---|---|
FailedShippingboOrdersReportService.java |
Service interface |
FailedShippingboOrdersReportServiceImpl.java |
Implementation with scheduling and email logic |
UserService.java |
Interface for fetching client basic info |
UserServiceImpl.java |
Implementation using MCRestTemplateService |
Modified Files
| File | Changes |
|---|---|
ShippingboOrderServiceImpl.java |
Added 7-day filter, excluded orders logging, new dependencies |
OrderRepository.java |
Added 3 new query methods for date-filtered operations |
Testing Checklist
-
Verify orders older than 7 days are excluded from sync -
Verify excluded orders are logged with their IDs -
Test weekly report email generation with failed orders -
Test weekly report email when no failed orders exist -
Verify configuration validation on application startup -
Test with disabled report ( enabled: false) -
Verify client info enrichment from User Service
Config Server Configuration
The following properties have been added to mydressin-order-service in Config Server:
Recipient Email
| Profile | Key | Value |
|---|---|---|
prod |
app.report.failed-shippingbo-orders.recipient-email |
amine@mydress-in.com |
rec |
app.report.failed-shippingbo-orders.recipient-email |
alt.z3-63pow6l@yopmail.com |
local |
app.report.failed-shippingbo-orders.recipient-email |
alt.z3-63pow6l@yopmail.com |
Cron Schedule
| Profile | Key | Value |
|---|---|---|
prod |
app.report.failed-shippingbo-orders.cron |
0 0 18 * * SUN |
rec |
app.report.failed-shippingbo-orders.cron |
0 0 18 * * SUN |
local |
app.report.failed-shippingbo-orders.cron |
0 0 18 * * SUN |
Enabled Flag
| Profile | Key | Value |
|---|---|---|
prod |
app.report.failed-shippingbo-orders.enabled |
true |
rec |
app.report.failed-shippingbo-orders.enabled |
true |
local |
app.report.failed-shippingbo-orders.enabled |
true |
Days Threshold
| Profile | Key | Value |
|---|---|---|
prod |
app.report.failed-shippingbo-orders.days-threshold |
7 |
rec |
app.report.failed-shippingbo-orders.days-threshold |
7 |
local |
app.report.failed-shippingbo-orders.days-threshold |
7 |
Email Template Requirement
Ensure the following email template constant is defined:
WEEKLY_FAILED_SHIPPINGBO_ORDERS_REPORT = "weekly_failed_shippingbo_orders_report.html"
Related Issues
Closes MS-241