Quick Start
After installing Monque and MongoDB, create a server entrypoint with a worker and an initial job:
initialize() creates indexes and prepares the scheduler. start() begins processing.
The handler receives the persisted job, including its MongoDB _id and data payload.
Replace console.log with the work your application needs to perform.
Worker failures
Section titled “Worker failures”If a handler throws or returns a rejected promise, Monque applies its retry policy.
Successful one-time jobs become completed; jobs that exhaust retries become failed.
See Retry & Backoff to configure delays and limits.
Jobs may run more than once after retries or crash recovery. Make workers idempotent: repeating a job should not repeat an unwanted side effect, such as charging an order twice. See Idempotent operations.
Delay a job
Section titled “Delay a job”uniqueKey prevents another pending or processing job with the same name and key from
being created. It does not prevent a later job after the earlier one completes or fails.
Schedule recurring work
Section titled “Schedule recurring work”The same registered worker handles recurring jobs. After a successful run, the job returns to pending with the next cron time. See Scheduling for cron expressions, timezone behavior, and cancellation.
Inspect jobs
Section titled “Inspect jobs”Use Job Management for queries and actions in server code, or add the dashboard to your Express application.
Handle Graceful Shutdown
Section titled “Handle Graceful Shutdown”Call stop() before closing your MongoDB client. It waits for running handlers up to
shutdownTimeout. If that limit is reached, jobs remain available for stale recovery.
Set scheduler options in your application’s code:
See MonqueOptions for all options and defaults,
and the Production Checklist before deployment.