← Back to Home

Background Jobs Reference

All scheduled services & queue-based processors in the BuyOff platform

12
Hosted Services
17
Job Processors
5 min
Queue Poll Interval
10
Batch Size

How It Works

Dual Execution Model — Timer-based hosted services run on schedule + Queue processors handle on-demand work
Admin Trigger
POST /api/BackgroundJob/trigger/{name}
BackgroundJob
DB Table
BackgroundJobExecutorService
Polls every 5 min, batch = 10
IBackgroundJobProcessor
Matched by JobType enum
Hosted services auto-run on their schedule. Queue processors are triggered via API or by other services enqueuing jobs. Many jobs have both a hosted service and a queue processor for redundancy.

Hosted Services (Timer / Interval Based)

12 Services
CacheWarmupService #1
Preloads category cache on application startup to avoid cold start delays for customers.
🕓 Once on startup Task.Delay(Infinite) One-time init
AdLifecycleService #2
Processes ad slot lifecycles: activates pending slots, expires slots past end date, updates booking statuses, handles content submission deadlines.
🕓 Every 1 hour PeriodicTimer Runs on startup + hourly
PromotionLifecycleService #3
Auto-expires promotions past their end date to prevent showing expired promotions to customers.
🕓 Every 1 hour Task.Delay loop
NotificationSchedulerService #4
Checks for scheduled notifications and sends them when their scheduled delivery time has arrived.
🕓 Every 15 minutes Task.Delay loop
NotificationCleanupService #5
Aggregates & cleans up old notification receipts (>60 days), archives expired notifications, deletes old analytics (>6 months). Runs during Indian downtime.
🕓 Weekly — Sun 2 AM IST Timezone calc
NotificationAnalyticsService #6
Calculates notification analytics: delivery rates, read rates, click-through rates, platform breakdown, and average read time.
🕓 Every 6 hours Task.Delay loop
LoginSessionCleanupService #7
Ends expired login sessions and deletes old login attempts based on configured retention period.
🕓 Every 24 hours (daily) PeriodicTimer Runs on startup + daily
SubscriptionLifecycleService #8
Sends expiry reminders (7, 3, 1 days), processes trial expirations, handles grace period expirations, auto-downgrades expired subscriptions, expires stale pending payments (24h+).
🕓 Every 6 hours PeriodicTimer
BackgroundJobExecutorService #9
Polls the BackgroundJob DB table for pending jobs and executes matching processors. Batch size of 10 jobs per cycle. The engine behind all queue-based processors.
🕓 Every 5 minutes PeriodicTimer Runs on startup + 5 min
TrackingBufferService #10
High-performance buffered event tracking using System.Threading.Channels. Non-blocking writes (<1ms), batched inserts to DB. Singleton service.
🕓 Every 5 sec / 100 events Channel<T> Singleton
TrackingAggregationService #11
Aggregates EngagementEvent data into EngagementSummary for near-real-time dashboard stats. Processes today + yesterday (catch-up). Uses Dapper stored procedure.
🕓 Every 1 hour PeriodicTimer
TrackingRetentionService #12
Deletes old EngagementEvent records (>60 days). Safe to delete after aggregation into EngagementSummary. Runs during Indian downtime hours.
🕓 Daily at 3 AM IST Timezone calc Retention: 60 days

Queue-Based Job Processors (Payload-Driven)

17 Processors

Triggered on-demand by enqueuing a row into the BackgroundJob DB table. Picked up by BackgroundJobExecutorService every 5 minutes (batch size 10). Admin can trigger manually via POST /api/BackgroundJob/trigger/{jobName}.

ShopPageCleanupProcessor #1
Fetches soft-deleted shop pages, extracts image URLs from layout JSON, deletes all images from Azure Blob Storage, then hard-deletes the shop page record.
ShopPageAssetCleanup (1) Payload: ShopPageId
ShopPageUpdateCleanupProcessor #2
Deletes images that were replaced or removed during shop page updates from Azure Blob Storage.
ShopPageUpdateCleanup (2) Payload: RemovedImageUrls[]
ShopDeletionCleanupProcessor #3
Comprehensive cleanup for soft-deleted shops: products, reviews, followers, shop pages, ad bookings, subscription usage, and Azure blob assets.
ShopDeletionCleanup (13) Payload: ShopId, ShopName
AdLifecycleProcessor #4
Processes ad slot lifecycle operations: expires old slots, updates bid statuses, and activates/expires ads. Mirrors the hosted service for on-demand use.
AdLifecycle (3) Payload: Empty
AdContentDeadlinesProcessor #5
Enforces ad content submission deadlines: sends reminder emails when content is due, auto-expires bookings that miss the 1-day-before-start deadline.
AdContentDeadlines (4) Payload: Empty
SubscriptionLifecycleProcessor #6
Processes queued subscription lifecycle events: expiry reminders, trial expirations, grace period handling, and auto-downgrade to Free tier.
SubscriptionLifecycle (5) Payload: Empty
NotificationSchedulerProcessor #7
Checks for scheduled notifications and sends them via the notification management service. Logs errors for failed sends.
NotificationScheduler (6) Payload: Empty
NotificationCleanupProcessor #8
Aggregates & deletes receipts older than 60 days, archives expired notifications, and deletes old analytics records (>6 months).
NotificationCleanup (7) Payload: Empty
NotificationAnalyticsProcessor #9
Calculates notification analytics: delivery rates, read rates, click-through rates, platform breakdowns (Web, Android, iOS), and average read time.
NotificationAnalytics (8) Payload: Empty
LoginSessionCleanupProcessor #10
Daily cleanup of expired login sessions and deletion of old login attempts based on retention period from LoginSecuritySettings.
LoginSessionCleanup (9) Payload: Empty
UserDeletionCleanupProcessor #11
Sends 24-hour reminder emails to users whose deletion grace period is expiring, then permanently deletes users whose grace period has fully expired.
UserDeletionCleanup (10) Payload: Empty
DataRetentionCleanupProcessor #12
Anonymizes PII in deleted user archive records after 6-year retention period. Complies with DPDPA 2023 & GST Act. Preserves transaction IDs for tax audits.
DataRetentionCleanup (14) Payload: Empty Retention: 6 years
TrackingAggregationProcessor #13
Aggregates EngagementEvent data into EngagementSummary for seller dashboard analytics. Processes today + yesterday (catch-up). Uses Dapper stored procedure.
TrackingAggregation (11) Payload: Empty
UnmappedCityResolutionProcessor #14
Resolves unmapped cities after admin creates a location alias. Bulk-updates all shops matching the city/state with the resolved LocationId.
UnmappedCityResolution (12) Payload: City, State, LocationId
PromotionLifecycleProcessor #15
Auto-expires promotions past their end date to prevent showing expired promotions to customers. Queue counterpart of PromotionLifecycleService.
PromotionLifecycle (15) Payload: Empty ✓ NEW
TrackingRetentionProcessor #16
Deletes old EngagementEvent records older than 60 days. Events are already aggregated into EngagementSummary, so raw events can be safely deleted. Batch: 10,000.
TrackingRetention (16) Payload: Empty ✓ NEW
CacheWarmupProcessor #17
Preloads category cache to avoid cold start delays. Can be triggered manually to re-warm caches without restarting the application.
CacheWarmup (17) Payload: Empty ✓ NEW
📋

Schedule Quick Reference

Hosted Service Interval Pattern Has Queue Processor?
CacheWarmupService Once on startup Task.Delay(Infinite) ✔ CacheWarmupProcessor
AdLifecycleService Every 1 hour PeriodicTimer ✔ AdLifecycleProcessor
PromotionLifecycleService Every 1 hour Task.Delay loop ✔ PromotionLifecycleProcessor
NotificationSchedulerService Every 15 minutes Task.Delay loop ✔ NotificationSchedulerProcessor
NotificationCleanupService Weekly — Sun 2 AM IST Timezone calc ✔ NotificationCleanupProcessor
NotificationAnalyticsService Every 6 hours Task.Delay loop ✔ NotificationAnalyticsProcessor
LoginSessionCleanupService Every 24 hours (daily) PeriodicTimer ✔ LoginSessionCleanupProcessor
SubscriptionLifecycleService Every 6 hours PeriodicTimer ✔ SubscriptionLifecycleProcessor
BackgroundJobExecutorService Every 5 minutes PeriodicTimer — (This IS the executor)
TrackingBufferService 5 sec / 100 events Channel<T> — (Real-time buffer)
TrackingAggregationService Every 1 hour PeriodicTimer ✔ TrackingAggregationProcessor
TrackingRetentionService Daily at 3 AM IST Timezone calc ✔ TrackingRetentionProcessor