Cloudflare 中文文档
Queues
编辑这个页面
跳转官方原文档
Set theme to dark (⇧+D)

Use Queues from Durable Objects

Publish to a queue from within a Durable Object.

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:

  1. Creates a Durable Object stub, or retrieves an existing one based on a userId.
  2. Passes request data to the Durable Object.
  3. 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.