Skip to content

Queue Consumer 0.1.0

キューのメッセージをWorkerのqueueハンドラーに配信します。

公開パッケージの内容を取得して検証済みです。

Hostの対応や受け入れ判断は、パッケージの公開とは別です。このバージョンを使う前に、利用先のHostで確認してください。

使い方

受信側の接続であり、WorkerVersionのBindingではありません。maxRetriesは再配信の回数です。任意のデッドレターキューは循環参照を作れません。網羅的なテスト例にはデッドレターキューも含まれています。

関連するForms: AtLeastOnceQueue 0.1.0 · ModuleWorker 0.1.0 · WorkerVersion 0.3.0

定義の説明(英語原文)

Attaches one Module Worker as the batch consumer of one At-Least-Once Queue, invoking its queue handler with message batches and redelivering messages that were not acknowledged. Consumption is inward activation and therefore an attachment, never a binding. One queue has at most one consumer, so a second attachment against the same queue is refused. A handler that returns normally without settling anything acknowledges the whole batch; one that throws retries every message it had not already acknowledged. maxRetries counts REDELIVERIES only — the first delivery does not count toward it — so a message is delivered at most 1 + maxRetries times, and a message that exhausts them moves to dead_letter_queue when one is declared and is dropped otherwise. The dead-letter copy is a new message there: new identity, new acceptance timestamp, and an attempt count starting again at 1 (decision 0020). Because that transfer resets the attempt count, dead_letter_queue MUST NOT lead back: a destination resolving to the queue this consumer drains, or closing a cycle of any length through the dead-letter graph, is refused before any mutation, because an exhausted message would circulate forever instead of coming to rest (decision 0026).

設定項目

項目名とスキーマ内の説明は、パッケージに含まれる英語の原文です。日本語の解説は定義に要件を追加するものではありません。

deadLetterQueue

任意 · object

Queue receiving messages that exhausted their retries. Without it, exhausted messages are dropped. It must not resolve to the queue this consumer drains, or close a cycle through other consumers' dead-letter destinations; a host refuses either before any mutation.

  • additionalProperties: false

maxBatchSize

必須 · integer

Largest number of messages delivered in one batch.

  • maximum: 100
  • minimum: 1

maxBatchTimeoutSeconds

必須 · integer

Longest time the host waits to fill a batch before delivering it, in seconds.

  • maximum: 60
  • minimum: 0

maxConcurrency

必須 · integer

Largest number of concurrent batch invocations.

  • maximum: 250
  • minimum: 1

maxRetries

必須 · integer

How many times a failed batch is redelivered before its messages go to the dead-letter queue or are dropped.

  • maximum: 100
  • minimum: 0

queue

必須 · object

Queue this consumer drains. Changing it replaces the attachment.

  • additionalProperties: false

retryDelaySeconds

必須 · integer

Delay before a failed batch becomes deliverable again, in seconds.

  • maximum: 43200
  • minimum: 0

worker

必須 · object

Module Worker whose queue handler receives the batches. Changing it replaces the attachment.

  • additionalProperties: false

設定の例

パッケージに含まれるfixtures/desired.jsonをそのまま掲載しています。完全なHost APIリクエストやOpenTofuの設定ではありません。例のリソース参照とArtifactのダイジェストは、実際の値に置き換えてください。このJSONだけでリソースが作成されることはありません。

json
{
  "deadLetterQueue": {
    "apiVersion": "edge.forms.takoform.com",
    "kind": "AtLeastOnceQueue",
    "name": "dead-letters"
  },
  "maxBatchSize": 10,
  "maxBatchTimeoutSeconds": 5,
  "maxConcurrency": 4,
  "maxRetries": 3,
  "queue": {
    "apiVersion": "edge.forms.takoform.com",
    "kind": "AtLeastOnceQueue",
    "name": "at-least-once-queue"
  },
  "retryDelaySeconds": 60,
  "worker": {
    "apiVersion": "edge.forms.takoform.com",
    "kind": "ModuleWorker",
    "name": "module-worker"
  }
}

例の原文を見る

設定のスキーマ全文(英語原文)

入れ子の項目、選択肢、すべてのスキーマ制約を以下に掲載しています。Hostが検証する意味上の規則は、定義の説明にも記載されています。

json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Attaches one Module Worker as the batch consumer of one At-Least-Once Queue, invoking its queue handler with message batches and redelivering messages that were not acknowledged. Consumption is inward activation and therefore an attachment, never a binding. One queue has at most one consumer, so a second attachment against the same queue is refused. A handler that returns normally without settling anything acknowledges the whole batch; one that throws retries every message it had not already acknowledged. maxRetries counts REDELIVERIES only — the first delivery does not count toward it — so a message is delivered at most 1 + maxRetries times, and a message that exhausts them moves to dead_letter_queue when one is declared and is dropped otherwise. The dead-letter copy is a new message there: new identity, new acceptance timestamp, and an attempt count starting again at 1 (decision 0020). Because that transfer resets the attempt count, dead_letter_queue MUST NOT lead back: a destination resolving to the queue this consumer drains, or closing a cycle of any length through the dead-letter graph, is refused before any mutation, because an exhausted message would circulate forever instead of coming to rest (decision 0026).",
  "properties": {
    "deadLetterQueue": {
      "additionalProperties": false,
      "description": "Queue receiving messages that exhausted their retries. Without it, exhausted messages are dropped. It must not resolve to the queue this consumer drains, or close a cycle through other consumers' dead-letter destinations; a host refuses either before any mutation.",
      "properties": {
        "apiVersion": {
          "const": "edge.forms.takoform.com",
          "type": "string"
        },
        "kind": {
          "const": "AtLeastOnceQueue",
          "type": "string"
        },
        "name": {
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        }
      },
      "required": [
        "apiVersion",
        "kind",
        "name"
      ],
      "type": "object",
      "x-takoform-required-interface": {
        "apiVersion": "interfaces.takoform.com/v1alpha1",
        "name": "edge.queue",
        "schemaDigest": "sha256:d8ed5c673cb544f5b2bd61aa66ac1c1a716276cf072232b3a0d06471403c2ff7",
        "version": "1.0.0"
      }
    },
    "maxBatchSize": {
      "description": "Largest number of messages delivered in one batch.",
      "maximum": 100,
      "minimum": 1,
      "type": "integer"
    },
    "maxBatchTimeoutSeconds": {
      "description": "Longest time the host waits to fill a batch before delivering it, in seconds.",
      "maximum": 60,
      "minimum": 0,
      "type": "integer"
    },
    "maxConcurrency": {
      "description": "Largest number of concurrent batch invocations.",
      "maximum": 250,
      "minimum": 1,
      "type": "integer"
    },
    "maxRetries": {
      "description": "How many times a failed batch is redelivered before its messages go to the dead-letter queue or are dropped.",
      "maximum": 100,
      "minimum": 0,
      "type": "integer"
    },
    "queue": {
      "additionalProperties": false,
      "description": "Queue this consumer drains. Changing it replaces the attachment.",
      "properties": {
        "apiVersion": {
          "const": "edge.forms.takoform.com",
          "type": "string"
        },
        "kind": {
          "const": "AtLeastOnceQueue",
          "type": "string"
        },
        "name": {
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        }
      },
      "required": [
        "apiVersion",
        "kind",
        "name"
      ],
      "type": "object",
      "x-takoform-required-interface": {
        "apiVersion": "interfaces.takoform.com/v1alpha1",
        "name": "edge.queue",
        "schemaDigest": "sha256:d8ed5c673cb544f5b2bd61aa66ac1c1a716276cf072232b3a0d06471403c2ff7",
        "version": "1.0.0"
      }
    },
    "retryDelaySeconds": {
      "description": "Delay before a failed batch becomes deliverable again, in seconds.",
      "maximum": 43200,
      "minimum": 0,
      "type": "integer"
    },
    "worker": {
      "additionalProperties": false,
      "description": "Module Worker whose queue handler receives the batches. Changing it replaces the attachment.",
      "properties": {
        "apiVersion": {
          "const": "edge.forms.takoform.com",
          "type": "string"
        },
        "kind": {
          "const": "ModuleWorker",
          "type": "string"
        },
        "name": {
          "maxLength": 63,
          "minLength": 1,
          "pattern": "^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$",
          "type": "string"
        }
      },
      "required": [
        "apiVersion",
        "kind",
        "name"
      ],
      "type": "object",
      "x-takoform-required-entrypoint": "queue",
      "x-takoform-required-interface": {
        "apiVersion": "interfaces.takoform.com/v1alpha1",
        "name": "worker.runtime",
        "schemaDigest": "sha256:ed2f8211aac5be94488d391945ca6aca7627a4ecbd261e39790093e887feae08",
        "version": "1.1.0"
      }
    }
  },
  "required": [
    "maxBatchSize",
    "maxBatchTimeoutSeconds",
    "maxConcurrency",
    "maxRetries",
    "queue",
    "retryDelaySeconds",
    "worker"
  ],
  "title": "Queue Consumer desired state",
  "type": "object"
}

ライフサイクル

役割: attachment

  • create
  • read
  • update
  • delete
  • import
  • observe

提供するInterface

ありません。

パッケージ参照

項目
KindQueueConsumer
Package digestsha256:3c6b332cf45df58f7a7db3eea8d03fec2aa4103b5e53c3452335639fa40a6266
Schema digestsha256:fffd4cc133eb03aa7fd57af9316a68fb9813544e78e0e55111df1341d8b8f453
Tagforms/k-mvsgozjomzxxe3ltfz2gc23pmzxxe3jomnxw2l2rovsxkzkdn5xhg5lnmvza/sha256-3c6b332cf45df58f7a7db3eea8d03fec2aa4103b5e53c3452335639fa40a6266
Source pathforms/releases/k-mvsgozjomzxxe3ltfz2gc23pmzxxe3jomnxw2l2rovsxkzkdn5xhg5lnmvza/sha256-3c6b332cf45df58f7a7db3eea8d03fec2aa4103b5e53c3452335639fa40a6266
署名セットe7f8a39311dd011b8467e97e7f300cabb9a6b06c

変更不可のパッケージを開く

4項目のFormRef
json
{
  "apiVersion": "edge.forms.takoform.com",
  "kind": "QueueConsumer",
  "definitionVersion": "0.1.0",
  "schemaDigest": "sha256:fffd4cc133eb03aa7fd57af9316a68fb9813544e78e0e55111df1341d8b8f453"
}