Background Jobs

BullMQ job queues with Redis for async processing. Services are reused in job processors via Dependency Injection.

Job System Structure

All job infrastructure lives in backend/src/lib/jobs/:

FilePurpose
factory.tsWorker creation and lifecycle
config.tsQueue configuration (concurrency, retries, backoff)
types.tsJob type definitions and payload interfaces
schedulers.tsCron-like scheduled job registration
health.tsQueue health monitoring and metrics
index.tsPublic API exports

Queues

QueuePurposeProcessor
notificationsEmail/SMS dispatchprocessors/notifications.ts
pdfPDF generation/conversionprocessors/pdf-conversion.ts
renditionsImage thumbnail generationprocessors/rendition.ts
hubspot-syncHubSpot CRM synchronizationprocessors/hubspotSyncProcessor.ts

Additional processors handle specialized tasks:

ProcessorPurpose
entra-sync.tsAzure Entra directory sync
document-reminder.tsDocument Obtaining reminder emails
escalation-scheduler.tsSLA escalation checks
reminder-scheduler.tsAppointment reminders
rejection-bundle.tsBatch rejection notifications
token-cleanup.tsExpired token removal

Specialized Queues

  • HubSpot sync: backend/src/lib/jobs/hubspot-sync-queue.ts — dedicated queue for HubSpot Integration with rate-limiting to respect API limits
  • Rendition backfill: backend/src/lib/jobs/rendition-backfill.ts — one-time migration job for generating thumbnails for existing Files

Process Supervision

Workers run as separate processes managed by supervisord.conf in the renewa-one/ root. The supervisor ensures workers restart on failure and provides log aggregation.

Redis Connection

Jobs use Upstash Redis in cloud environments and local ioredis in development. Connection is configured through the DI container’s infrastructure layer.

See Also