The following example shows you how to write a Worker script to publish to Cloudflare Queues from within a Durable Object.
Prerequisites:
Configure your wrangler.toml
file as follows:
The following Worker script:
- Creates a Durable Object stub, or retrieves an existing one based on a userId.
- Passes request data to the Durable Object.
- Publishes to a queue from within the Durable Object.
The constructor()
in the Durable Object makes your Environment
available (in scope) on this.env
to the fetch()
handler in the Durable Object.
Thank you for helping improve Cloudflare's documentation!