Implement a single background thread that wakes up periodically to retrieve any available TDRs, this thread should omit the username and TdrType arguments when calling this function. This is the simplest level of integration. This approach will satisfy situations that can operate with data that is out of date by the interval used by the single background thread. This approach is designed to address the Use-case-01: Bulk Reporting.
The recommended interval for this approach is 10 minutes. The reason for an interval is to maintain optimal responsiveness and throughput of the content publisher system.
Then using only Pattern 1, for recovery purposes, the single background thread need only save the last TDR ID that was successfully processed. The content publisher guarantees that all TDR IDs will be unique per customer and monotonically increasing. The single background thread only needs to check:
last_processed_tdr_id < current_tdr_id
If true, then the TDR has not been seen before by the caller, and should be processed.