Skip to content

3. Queues & events

Dispatch a background job when a domain event fires.

Queue config

New apps default to the database driver. Confirm config/queue.ts points at your SQLite connection and that the jobs table migration has run.

See Queues & jobs for Redis workers and failed-job retry.

Event + listener

bash
tyravel make:event UserRegistered
tyravel make:listener SendWelcomeEmail --event=UserRegistered

Register the listener in your event service provider (scaffolded by tyravel new).

Queued listener

Implement ShouldQueue on the listener (or dispatch a job from handle) so mail sends outside the request cycle.

Run the worker

bash
tyravel queue:work

In tests, drain the queue explicitly — see Testing.

examples/hello-world uses UserRegistered → queued SendWelcomeEmail; call await t.drainQueue() in tests before asserting mail.

Next

Realtime & deploy — broadcast events over the native WebSocket hub.

Released under the MIT License.