Queue Management

Queue Dashboard

v1.2.4

Built-in web dashboard for monitoring and managing your background job queues. Inspired by Laravel Horizon, the Queue Dashboard provides real-time visibility into your job processing pipeline.

Real-time Stats

Monitor pending, failed, and processed job counts at a glance

Job Management

View pending and failed jobs with full payload details

Retry Failed Jobs

One-click retry for failed jobs directly from the dashboard

Clear Queue

Quickly clear all jobs when needed for development or reset

Quick Setup

Mount the Queue Dashboard in your application with just a few lines of code. The dashboard will be available at /canx-queue.

app.ts
1import { createApp, queue, QueueController } from "canxjs";
2
3const app = createApp({ port: 3000 });
4
5// Mount the Queue Dashboard at /canx-queue
6app.routes((router) => {
7 router.controller('/canx-queue', QueueController);
8});
9
10app.listen();

Working with Jobs

Dispatch background jobs to queues and process them asynchronously. Jobs can be immediate or delayed.

jobs.ts
1import { queue } from "canxjs";
2
3// Dispatch a job to the queue
4await queue.dispatch("send-email", {
5 to: "user@example.com",
6 subject: "Welcome!",
7 body: "Thank you for signing up."
8});
9
10// Dispatch with delay (5 minutes)
11await queue.later("send-reminder", { userId: 123 }, 300);
12
13// Process jobs
14queue.process("send-email", async (job) => {
15 await sendEmail(job.data);
16 console.log(`Email sent to ${job.data.to}`);
17});

Queue API

Programmatically interact with the queue using the Queue API. Get statistics, manage failed jobs, and more.

queue-api.ts
1// Get queue statistics
2const stats = await queue.getStats();
3console.log(stats);
4// { pending: 12, failed: 2, processed: 158 }
5
6// Get failed jobs
7const failedJobs = await queue.getFailed();
8
9// Retry a specific job
10await queue.retry(jobId);
11
12// Clear all jobs
13await queue.clear();

Dashboard API Endpoints

MethodEndpointDescription
GET
/canx-queue/api/statsGet queue statistics
GET
/canx-queue/api/jobs/failedList failed jobs
GET
/canx-queue/api/jobs/pendingList pending jobs
POST
/canx-queue/api/jobs/retry/:idRetry a failed job
POST
/canx-queue/api/clearClear all jobs

Queue Drivers

Memory Driver

Default driver, perfect for development and testing. Jobs are stored in memory.

MemoryDriver

Redis Driver

Production-ready driver with persistence. Requires Redis server.

RedisDriver

Next Steps

Learn more about background job processing and event-driven architecture.