---
title: "Background worker and queue in 2026: BullMQ, Celery or Sidekiq"
url: https://while.sh/en/guides/background-worker-queue/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-19
---

# Run a background worker with BullMQ, Celery or Sidekiq, with your AI (2026)

Sending emails, running exports and heavy processing don't belong in your requests. Connected to while over MCP, your AI deploys the worker that handles them in the background, with its queue.

> **The short version.** Over MCP, your AI deploys the worker that processes your BullMQ, Celery or Sidekiq queue, with its Redis-compatible cache. What matters, like deleting a database, waits for a person's approval.

## Prerequisites

- An app that puts tasks in a queue: BullMQ, Celery, RQ or Sidekiq.
- An AI that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.

## Step 1: Give your AI this message

Open your AI in your app's folder, and paste this message into it:

```text titre="The message to give your AI"
Connect to while with my account (while.sh/agents), then put my app on while.
```

Your AI adds while's MCP server itself. If it asks you to, restart it. On the first call to while, a page opens in your browser. In Claude Code, if it doesn't open, type /mcp, choose while, then Authenticate. On that page, choose "A new app", then click Authorize.

## Step 2: Open your app

Your AI gives you your app's address, for example `https://mon-appli.while.cloud`, over HTTPS.

## What your AI does

It adds the worker and its queue to while.yaml:

```yaml titre="while.yaml"
apiVersion: while/v1
project: mon-appli
services:
  - name: web
    port: 3000
  - name: worker
    type: worker
    command: [node, worker.js]
caches:
  - name: file
    durable: true
```

The worker runs nonstop, with no public address, and with the same code as your app. Its queue lives in a durable Redis-compatible cache: nothing is lost on restart. Its address, password included, arrives in `REDIS_URL`, as in this BullMQ worker (source 1):

```js titre="worker.js"
import { Worker } from 'bullmq';
import IORedis from 'ioredis';

const connection = new IORedis(process.env.REDIS_URL, { maxRetriesPerRequest: null });

new Worker('emails', async (job) => {
  await envoyerEmail(job.data);
}, { connection });
```


<figure class="illus"><img src="/illustrations/guide-fonction-garde-1200.webp" srcset="/illustrations/guide-fonction-garde-768.webp 768w, /illustrations/guide-fonction-garde-1200.webp 1200w" sizes="(min-width: 48rem) 46rem, 100vw" width="1536" height="1024" loading="lazy" decoding="async" alt="A worker and its queue with while: credentials kept out of the AI's reach, every call logged in the history, a person's approval for what matters and a daily backup, in France" /><figcaption>Around every app, while keeps the credentials, the history, the approvals and the backups.</figcaption></figure>

## Run a Celery worker

> You, to your AI: Add a Celery worker for the exports.

Your AI declares the worker with the command `celery -A monappli worker`, connected to the same cache: it gives `REDIS_URL` to Celery, with `broker=os.environ['REDIS_URL']`.

## See what your worker is doing

> You, to your AI: Why are the emails going out late?

Your AI reads the worker's logs in while, finds the task that is stuck and fixes it.

## Add memory

> You, to your AI: Give the exports worker more memory.

Your AI changes `resources` in while.yaml, and the worker restarts with it on the next deployment.

## Go back to the previous version

> You, to your AI: Go back to the previous version of the worker.

The previous version of the worker resumes in a few seconds. Your AI reads the error in the logs, fixes it and deploys again.

## Next steps

- [Run a scheduled job](/en/guides/run-cron-job/)
- [Add a Redis-compatible cache](/en/guides/add-redis-cache/)
- [Deploy a Ruby on Rails app](/en/guides/deploy-rails/)

## Sources

1. [BullMQ, workers](https://docs.bullmq.io/guide/workers), 2026-11-02

## Questions

### Does my worker run twice during an update?

No: a new version replaces the old one, and the two never run at the same time.

### Celery, RQ or Sidekiq?

All of them: the worker runs the command of your choice, with the same code as your app.

### What about a job that runs at a fixed time?

A scheduled job costs less: it only runs for as long as the work takes.

### Does my worker have a public address?

No, it runs without an address: no one can call it from outside.

### Where do my app and its data run?

In France, at Nextmap. The database is backed up every day, with a way back over 14 days, once a person approves.
