Skip to content

Set Up BullMQ Background Queue to Process Document Analysis and Stellar Anchoring Jobs Asynchronously #225

@mftee

Description

@mftee

Description:
Offload document analysis and blockchain anchoring to an independent background job queue using BullMQ and Redis, so uploads return immediately without blocking.

Tasks:

  • Create src/queue/queue.module.ts
  • Define a document-processing queue with two job types: analyze and anchor
  • Create DocumentProcessor (BullMQ worker) that handles analyze jobs by calling RiskAssessmentService and anchor jobs by calling StellarService
  • Update the upload endpoint to enqueue an analyze job after creating the document record
  • Update POST /api/documents/:id/verify to enqueue an anchor job instead of calling Stellar synchronously

Acceptance Criteria:

  • Uploading a document returns immediately with a 202 Accepted status
  • The analyze job runs in the background and updates the document risk score
  • The anchor job runs and creates a VerificationRecord on completion
  • Failed jobs are retried up to 3 times with exponential backoff

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions