The queue namespace pushes a message onto a named queue through the configured
messaging provider. A queue is point-to-point: each message is handled by exactly one
consumer, declared elsewhere with on queue.
When to use
Use a queue to hand work off so a route can return immediately, when each message
should be processed once by a single consumer (sending an email, resizing an image).
To broadcast an event to several independent subscribers instead, use
topic.
See Process work asynchronously with a queue for the producer, the consumer, and ack/nack semantics.
Operations
queue.push enqueues a message. Add as <Schema> to validate and strip it to the
declared fields before it goes out:
queue.push "welcome_emails" as Signup, payload| Name | Signature | Summary |
|---|---|---|
queue.push | queue.push "<queue>" [as Schema], payload | Enqueues a point-to-point message. |
The consumer is a top-level handler, not a method on this namespace:
on queue "welcome_emails" take signup as Signup
log.info("sending to #{signup.email}")Notes
- The messaging provider must be configured and reachable before
marreta serve. Runmarreta doctorto check the connection. - A consumer acknowledges on a clean run. A runtime error or a schema mismatch nacks
without requeue, and only
nack requeueretries. See ack and nack.