跳到正文

消息队列

托管消息队列:发布与消费消息、批量发送、死信队列(DLQ)、重投递与推送订阅。

1. 概览

基础路径: https://api.infrai.cc/v1/queue
鉴权头: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/queue capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/queue/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

2. 方法 (15)

2.1queue.publish

POST /v1/queue/publish

向队列发布消息,可选延迟。

参数

名称类型必填说明
queuestring
必填
队列名称。
payloadobject
必填
消息负载。
delay_secondsnumber可选投递前的延迟(秒)。
0–604800default: 0
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

{ message_id }
名称类型说明
message_idstringmessage的唯一标识符
pattern: ^qmsg_[A-Za-z0-9]{20,}$
queuestring此消息或订阅所属的队列名
ackedboolean消息是否已确认(queue.ack 响应)
nackedboolean消息是否已拒绝(queue.nack 响应)
requeueboolean被拒消息是否已重新入队(queue.nack 响应)
account_idstring拥有此资源的账户标识
payloadobject消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
status"available" | "in_flight" | "deleted" | "dlq"当前资源状态
delivery_countinteger消息投递尝试次数
≥ 0
visibility_timeout_expires_atstring | nullISO 8601 时间戳:visibility timeout expires(ISO 8601)
format: date-time
published_atstring事件发布时间(ISO 8601)
format: date-time
available_atstringISO 8601 时间戳:the message becomes available for consumption(ISO 8601)
format: date-time
priorityintegerMX 或 SRV 记录的优先级
0–10default: 0
message_group_idstring | null仅 FIFO。
deduplication_idstring | null仅 FIFO;5 分钟去重窗口。

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/publish \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample", "payload": {}}'

2.2queue.create

POST /v1/queue/create

创建一个消息队列

参数

名称类型必填说明
namestring
必填
队列名称
3–80 charspattern: ^[a-z0-9._-]+$
type"standard" | "fifo"可选队列类型:standard 标准 / fifo 先进先出
default: "standard"
dead_letter_queuestring可选接收失败消息的死信队列名(须已存在)
max_retriesnumber可选转入 DLQ 前允许的 nack 次数
≥ 1
message_retention_daysnumber可选消息保留天数
1–30
visibility_timeout_defaultnumber可选默认可见性超时(租约)秒数
0–43200
enable_priorityboolean可选是否启用优先级
idempotency_keystring可选幂等键,避免重复创建

返回

QueueRecord { queue, type, dead_letter_queue?, max_retries, visibility_timeout_default }
名称类型说明
namestring资源的可读名称
3–80 charspattern: ^[a-z0-9._-]+$
type"standard" | "fifo"资源类型标识
account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
message_retention_daysinteger队列消息保留天数
1–30
max_message_size_kbinteger最大消息大小(KB)
1–256
visibility_timeout_defaultinteger默认可见性超时(秒)。
0–43200
delivery_delay_secondsinteger消息投递前的延迟(秒)
0–900
enable_priorityboolean是否启用基于优先级的投递
dlq_namestring | null死信队列名称
max_receive_countinteger消息转入死信队列前的 Nack 次数。
≥ 1
created_atstring资源创建时间(ISO 8601)
format: date-time
updated_atstring资源最后更新时间(ISO 8601)
format: date-time

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "example"}'

2.3queue.get

GET /v1/queue/get/{queue}

获取队列配置详情

参数

名称类型必填说明
queuestring
必填
队列名称

返回

QueueRecord { queue, type, dead_letter_queue?, max_retries, visibility_timeout_default }
名称类型说明
namestring资源的可读名称
3–80 charspattern: ^[a-z0-9._-]+$
type"standard" | "fifo"资源类型标识
account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
message_retention_daysinteger队列消息保留天数
1–30
max_message_size_kbinteger最大消息大小(KB)
1–256
visibility_timeout_defaultinteger默认可见性超时(秒)。
0–43200
delivery_delay_secondsinteger消息投递前的延迟(秒)
0–900
enable_priorityboolean是否启用基于优先级的投递
dlq_namestring | null死信队列名称
max_receive_countinteger消息转入死信队列前的 Nack 次数。
≥ 1
created_atstring资源创建时间(ISO 8601)
format: date-time
updated_atstring资源最后更新时间(ISO 8601)
format: date-time

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/queue/get/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.4queue.list

GET /v1/queue/list

分页列出所有队列

参数

名称类型必填说明
cursorstring可选分页游标,来自上一页 next_cursor
limitnumber可选每页返回数量

返回

{ items: QueueRecord[], next_cursor? }
名称类型说明
itemsobject[]本页结果条目数组
items[].namestring此资源的可读名称
3–80 charspattern: ^[a-z0-9._-]+$
items[].type"standard" | "fifo"资源类型标识
items[].account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
items[].message_retention_daysinteger队列消息保留天数
1–30
items[].max_message_size_kbinteger最大消息大小(KB)
1–256
items[].visibility_timeout_defaultinteger默认可见性超时(秒)。
0–43200
items[].delivery_delay_secondsinteger消息投递前的延迟(秒)
0–900
items[].enable_priorityboolean是否启用基于优先级的投递
items[].dlq_namestring | null死信队列名称
items[].max_receive_countinteger消息转入死信队列前的 Nack 次数。
≥ 1
items[].created_atstring此资源创建的 ISO 8601 时间戳
format: date-time
items[].updated_atstring此资源最后更新的 ISO 8601 时间戳
format: date-time
next_cursorstring | null获取下一页的不透明游标;null 或不存在表示最后一页

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/queue/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.5queue.update

PATCH /v1/queue/update/{queue}

更新队列配置

参数

名称类型必填说明
queuestring
必填
队列名称
dead_letter_queuestring可选死信队列名
max_retriesnumber可选转入 DLQ 前允许的 nack 次数
≥ 1
message_retention_daysnumber可选消息保留天数
1–30
visibility_timeout_defaultnumber可选默认可见性超时秒数
0–43200
enable_priorityboolean可选是否启用优先级
idempotency_keystring可选幂等键,避免重复执行

返回

QueueRecord { queue, max_retries, visibility_timeout_default }
名称类型说明
namestring资源的可读名称
3–80 charspattern: ^[a-z0-9._-]+$
type"standard" | "fifo"资源类型标识
account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
message_retention_daysinteger队列消息保留天数
1–30
max_message_size_kbinteger最大消息大小(KB)
1–256
visibility_timeout_defaultinteger默认可见性超时(秒)。
0–43200
delivery_delay_secondsinteger消息投递前的延迟(秒)
0–900
enable_priorityboolean是否启用基于优先级的投递
dlq_namestring | null死信队列名称
max_receive_countinteger消息转入死信队列前的 Nack 次数。
≥ 1
created_atstring资源创建时间(ISO 8601)
format: date-time
updated_atstring资源最后更新时间(ISO 8601)
format: date-time

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X PATCH https://api.infrai.cc/v1/queue/update/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

2.6queue.delete

DELETE /v1/queue/delete/{queue}

删除一个队列

参数

名称类型必填说明
queuestring
必填
队列名称
idempotency_keystring可选幂等键,避免重复执行

返回

{ queue, deleted }
名称类型说明
queuestring(尝试)删除的队列名称
deletedboolean队列是否已删除
status"not_found" | null队列不存在时为 "not_found"(deleted=false)

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X DELETE https://api.infrai.cc/v1/queue/delete/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.7queue.purge

POST /v1/queue/purge/{queue}

清空队列中所有消息

参数

名称类型必填说明
queuestring
必填
队列名称
idempotency_keystring可选幂等键,避免重复执行

返回

{ queue, purged }
名称类型说明
queuestring(尝试)清空的队列名称
purgedinteger | nullmessages purged数量
foundboolean队列不存在时为 false(省略 purged)

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/purge/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample"}'

2.8queue.stats

GET /v1/queue/stats/{queue}

获取队列统计指标

参数

名称类型必填说明
queuestring
必填
队列名称

返回

QueueStats { queue, available, in_flight, dlq, oldest_age_seconds? }
名称类型说明
queuestring此消息或订阅所属的队列名
message_countintegeravailable + in_flight。
≥ 0
available_countintegermessages available for consumption数量
≥ 0
in_flight_countintegermessages currently being processed数量
≥ 0
delayed_countintegerdelayed messages数量
≥ 0
dlq_countintegermessages in the dead-letter queue数量
≥ 0
oldest_message_age_secondsinteger队列中最旧消息的存活时间(秒)
≥ 0

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/queue/stats/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.9queue.publish_batch

POST /v1/queue/publish_batch

批量发布多条消息到队列

参数

名称类型必填说明
queuestring
必填
队列名称
messagesQueueMessage[]
必填
待发布的消息数组
1–100 items
idempotency_keystring可选幂等键,避免重复发布

返回

{ message_ids }
名称类型说明
itemsobject[]本页结果条目数组
items[].message_idstringmessage的唯一标识符
pattern: ^qmsg_[A-Za-z0-9]{20,}$
items[].queuestring此消息或订阅所属的队列名
items[].ackedboolean消息是否已确认(queue.ack 响应)
items[].nackedboolean消息是否已拒绝(queue.nack 响应)
items[].requeueboolean被拒消息是否已重新入队(queue.nack 响应)
items[].account_idstring拥有此资源的账户标识
items[].payloadobject消息或请求正文的载荷数据
items[].headersobject | null请求或响应中包含的自定义 HTTP 头
items[].status"available" | "in_flight" | "deleted" | "dlq"此资源当前状态
items[].delivery_countintegerdelivery attempts for this message数量
≥ 0
items[].visibility_timeout_expires_atstring | null可见性超时过期的 ISO 8601 时间戳
format: date-time
items[].published_atstring事件发布的 ISO 8601 时间戳
format: date-time
items[].available_atstring消息可被消费的 ISO 8601 时间戳
format: date-time
items[].priorityintegerMX 或 SRV 记录的优先级
0–10default: 0
items[].message_group_idstring | null仅 FIFO。
items[].deduplication_idstring | null仅 FIFO;5 分钟去重窗口。
next_cursorstring | null获取下一页的不透明游标;null 或不存在表示最后一页

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/publish_batch \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample", "messages": [{"payload": {}}]}'

2.10queue.consume

POST /v1/queue/consume

从队列拉取一批消息消费

参数

名称类型必填说明
queuestring
必填
队列名称
max_messagesnumber可选单次最多拉取的消息数
1–100default: 10
visibility_timeoutnumber可选本批消息的租约秒数;默认取队列配置
0–43200

返回

{ messages: QueueMessage[] }
名称类型说明
itemsobject[]本页结果条目数组
items[].message_idstringmessage的唯一标识符
pattern: ^qmsg_[A-Za-z0-9]{20,}$
items[].queuestring此消息或订阅所属的队列名
items[].ackedboolean消息是否已确认(queue.ack 响应)
items[].nackedboolean消息是否已拒绝(queue.nack 响应)
items[].requeueboolean被拒消息是否已重新入队(queue.nack 响应)
items[].account_idstring拥有此资源的账户标识
items[].payloadobject消息或请求正文的载荷数据
items[].headersobject | null请求或响应中包含的自定义 HTTP 头
items[].status"available" | "in_flight" | "deleted" | "dlq"此资源当前状态
items[].delivery_countintegerdelivery attempts for this message数量
≥ 0
items[].visibility_timeout_expires_atstring | null可见性超时过期的 ISO 8601 时间戳
format: date-time
items[].published_atstring事件发布的 ISO 8601 时间戳
format: date-time
items[].available_atstring消息可被消费的 ISO 8601 时间戳
format: date-time
items[].priorityintegerMX 或 SRV 记录的优先级
0–10default: 0
items[].message_group_idstring | null仅 FIFO。
items[].deduplication_idstring | null仅 FIFO;5 分钟去重窗口。
next_cursorstring | null获取下一页的不透明游标;null 或不存在表示最后一页

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/consume \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample"}'

2.11queue.ack

POST /v1/queue/ack

确认一条已消费的消息

参数

名称类型必填说明
queuestring
必填
队列名称
message_idstring
必填
消息 ID
pattern: ^qmsg_[A-Za-z0-9]{20,}$
idempotency_keystring可选幂等键,避免重复执行

返回

{ message_id, acked }
名称类型说明
message_idstringmessage的唯一标识符
pattern: ^qmsg_[A-Za-z0-9]{20,}$
queuestring此消息或订阅所属的队列名
ackedboolean消息是否已确认(queue.ack 响应)
nackedboolean消息是否已拒绝(queue.nack 响应)
requeueboolean被拒消息是否已重新入队(queue.nack 响应)
account_idstring拥有此资源的账户标识
payloadobject消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
status"available" | "in_flight" | "deleted" | "dlq"当前资源状态
delivery_countinteger消息投递尝试次数
≥ 0
visibility_timeout_expires_atstring | nullISO 8601 时间戳:visibility timeout expires(ISO 8601)
format: date-time
published_atstring事件发布时间(ISO 8601)
format: date-time
available_atstringISO 8601 时间戳:the message becomes available for consumption(ISO 8601)
format: date-time
priorityintegerMX 或 SRV 记录的优先级
0–10default: 0
message_group_idstring | null仅 FIFO。
deduplication_idstring | null仅 FIFO;5 分钟去重窗口。

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/ack \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample", "message_id": "hello"}'

2.12queue.nack

POST /v1/queue/nack

否认一条消息,可重新入队或转入死信

参数

名称类型必填说明
queuestring
必填
队列名称
message_idstring
必填
消息 ID
pattern: ^qmsg_[A-Za-z0-9]{20,}$
requeueboolean可选true 重新入队;false 直接转入死信
default: true
idempotency_keystring可选幂等键,避免重复执行

返回

{ message_id, nacked, requeued }
名称类型说明
message_idstringmessage的唯一标识符
pattern: ^qmsg_[A-Za-z0-9]{20,}$
queuestring此消息或订阅所属的队列名
ackedboolean消息是否已确认(queue.ack 响应)
nackedboolean消息是否已拒绝(queue.nack 响应)
requeueboolean被拒消息是否已重新入队(queue.nack 响应)
account_idstring拥有此资源的账户标识
payloadobject消息或请求体的负载数据
headersobject | null请求或响应中包含的自定义 HTTP 头
status"available" | "in_flight" | "deleted" | "dlq"当前资源状态
delivery_countinteger消息投递尝试次数
≥ 0
visibility_timeout_expires_atstring | nullISO 8601 时间戳:visibility timeout expires(ISO 8601)
format: date-time
published_atstring事件发布时间(ISO 8601)
format: date-time
available_atstringISO 8601 时间戳:the message becomes available for consumption(ISO 8601)
format: date-time
priorityintegerMX 或 SRV 记录的优先级
0–10default: 0
message_group_idstring | null仅 FIFO。
deduplication_idstring | null仅 FIFO;5 分钟去重窗口。

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/nack \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample", "message_id": "hello"}'

2.13queue.dlq.list

GET /v1/queue/dlq/list/{queue}

分页列出死信队列中的消息

参数

名称类型必填说明
queuestring
必填
队列名称
cursorstring可选分页游标,来自上一页 next_cursor
limitnumber可选每页返回数量

返回

{ items: QueueMessage[], next_cursor? }
名称类型说明
itemsobject[]本页结果条目数组
items[].message_idstringmessage的唯一标识符
pattern: ^qmsg_[A-Za-z0-9]{20,}$
items[].queuestring此消息或订阅所属的队列名
items[].ackedboolean消息是否已确认(queue.ack 响应)
items[].nackedboolean消息是否已拒绝(queue.nack 响应)
items[].requeueboolean被拒消息是否已重新入队(queue.nack 响应)
items[].account_idstring拥有此资源的账户标识
items[].payloadobject消息或请求正文的载荷数据
items[].headersobject | null请求或响应中包含的自定义 HTTP 头
items[].status"available" | "in_flight" | "deleted" | "dlq"此资源当前状态
items[].delivery_countintegerdelivery attempts for this message数量
≥ 0
items[].visibility_timeout_expires_atstring | null可见性超时过期的 ISO 8601 时间戳
format: date-time
items[].published_atstring事件发布的 ISO 8601 时间戳
format: date-time
items[].available_atstring消息可被消费的 ISO 8601 时间戳
format: date-time
items[].priorityintegerMX 或 SRV 记录的优先级
0–10default: 0
items[].message_group_idstring | null仅 FIFO。
items[].deduplication_idstring | null仅 FIFO;5 分钟去重窗口。
next_cursorstring | null获取下一页的不透明游标;null 或不存在表示最后一页

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/queue/dlq/list/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.14queue.dlq.redrive

POST /v1/queue/dlq/redrive/{queue}

将死信消息重投回原队列

参数

名称类型必填说明
queuestring
必填
队列名称
message_idstring可选重投单条消息的 ID;省略则批量重投
pattern: ^qmsg_[A-Za-z0-9]{20,}$
sincestring可选批量重投:该时刻及之后进入死信的全部消息
format: date-time
idempotency_keystring可选幂等键,避免重复重投

返回

{ queue, redriven }
名称类型说明
okboolean重投是否已启动
redriven_countinteger | nullmessages redriven数量

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/dlq/redrive/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample"}'

2.15queue.push_subscribe

POST /v1/queue/push_subscribe/{queue}

为队列配置推送订阅

参数

名称类型必填说明
queuestring
必填
队列名称
urlstring
必填
https 推送目标地址(经 SSRF 校验)
format: uri
secretstring可选对推送请求做 HMAC 签名的密钥
max_retriesnumber可选推送失败重试次数
≥ 0
visibility_timeoutnumber可选可见性超时秒数
0–43200
dead_letter_queuestring可选死信队列名
idempotency_keystring可选幂等键,避免重复订阅

返回

PushSubscription { subscription_id, queue, url }
名称类型说明
subscription_idstringsubscription的唯一标识符
pattern: ^sub_[A-Za-z0-9]{20,}$
queuestring此消息或订阅所属的队列名
account_idstring拥有此资源的账户标识
pattern: ^acct_(anon|email)_[A-Za-z0-9_]…
concurrencyintegerconcurrent consumers for push subscriptions数量
≥ 1
max_retriesinteger最大投递重试次数
≥ 0
dead_letter_queuestring | null失败消息的死信队列名称
activeboolean该资源当前是否活跃
started_atstring执行开始时间(ISO 8601)
format: date-time
stopped_atstring | nullISO 8601 时间戳:the subscription was stopped(ISO 8601)
format: date-time

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/queue/push_subscribe/QUEUE \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"queue": "sample", "url": "https://example.com/callback"}'

3. 全部能力

本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。

queue.ackPOST /v1/queue/ack

Acknowledge (ack) a consumed message to remove it from the queue.

参数 (3)
名称类型必填说明
queuestring必填Queue name this message or subscription belongs to
message_idstring必填Unique identifier for this message
pattern: ^qmsg_[A-Za-z0-9]{20,}$
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.consumePOST /v1/queue/consume

Pull a batch of messages from a queue for processing.

参数 (3)
名称类型必填说明
queuestring必填Queue name this message or subscription belongs to
max_messagesinteger可选Maximum number of messages to consume in one batch
1–100default: 10
visibility_timeoutinteger | null可选Lease seconds; defaults to queue's visibility_timeout_default.
0–43200
queue.createPOST /v1/queue/create

Create a message queue (standard or FIFO, with optional dead-letter queue).

参数 (8)
名称类型必填说明
namestring必填Human-readable name for this resource
3–80 charspattern: ^[a-z0-9._-]+$
type"standard" | "fifo"可选Type discriminator for this resource
default: "standard"
dead_letter_queuestring | null可选Name of an existing queue to receive failed messages.
max_retriesinteger | null可选Nack count before moving to DLQ.
≥ 1
message_retention_daysinteger | null可选Number of days to retain queue messages
1–30
visibility_timeout_defaultinteger | null可选Default visibility timeout in seconds
0–43200
enable_priorityboolean | null可选Whether priority-based delivery is enabled
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.deleteDELETE /v1/queue/delete/{queue}

Delete a message queue and discard all of its pending messages (use queue.purge to keep the queue); idempotent.

参数 (1)
名称类型必填说明
queuestring必填Path parameter.
queue.dlq.listGET /v1/queue/dlq/list/{queue}

List messages in a queue's dead-letter queue (DLQ) with pagination.

参数 (1)
名称类型必填说明
queuestring必填Path parameter.
queue.dlq.redrivePOST /v1/queue/dlq/redrive/{queue}

Redrive dead-letter messages back to the source queue, individually or in bulk.

参数 (4)
名称类型必填说明
queuestring必填Queue name this message or subscription belongs to
message_idstring | null可选Redrive a single message; omit for bulk.
pattern: ^qmsg_[A-Za-z0-9]{20,}$
sincestring | null可选Bulk redrive all DLQ messages dead-lettered at/after this time.
format: date-time
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.getGET /v1/queue/get/{queue}

Retrieve a queue's configuration details.

参数 (1)
名称类型必填说明
queuestring必填Path parameter.
queue.listGET /v1/queue/list

List all message queues with pagination.

无请求参数。

queue.nackPOST /v1/queue/nack

Negatively acknowledge (nack) a message to requeue it or route it to the DLQ.

参数 (4)
名称类型必填说明
queuestring必填Queue name this message or subscription belongs to
message_idstring必填Unique identifier for this message
pattern: ^qmsg_[A-Za-z0-9]{20,}$
requeueboolean可选false → straight to DLQ.
default: true
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.publishPOST /v1/queue/publish

Publish a single message to a queue (idempotent).

参数 (8)
名称类型必填说明
queuestring必填Queue name this message or subscription belongs to
payloadobject必填Payload data for the message or request body
delay_secondsinteger可选0..604800 (7 days).
0–604800default: 0
priorityinteger可选Priority for MX or SRV records
0–9default: 0
message_group_idstring | null可选FIFO only.
deduplication_idstring | null可选FIFO only; 5-min dedup window.
headersobject | null可选Custom HTTP headers to include in requests or responses
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.publish_batchPOST /v1/queue/publish_batch

Publish multiple messages to a queue in a single batch.

参数 (3)
名称类型必填说明
queuestring必填Queue name this message or subscription belongs to
messagesobject[]必填List of messages to publish or process
1–100 items
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.purgePOST /v1/queue/purge/{queue}

Purge all messages from a queue.

参数 (2)
名称类型必填说明
queuestring必填Name of the queue to purge.
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.push_subscribePOST /v1/queue/push_subscribe/{queue}

Configure a push subscription to deliver queue messages to a callback URL.

参数 (7)
名称类型必填说明
queuestring必填Queue name this message or subscription belongs to
urlstring必填https:// push target; SSRF-validated.
format: uri
secretstring | null可选HMAC signing secret for pushed deliveries.
max_retriesinteger | null可选Maximum number of delivery retries
≥ 0
visibility_timeoutinteger | null可选Visibility timeout in seconds
0–43200
dead_letter_queuestring | null可选Dead-letter queue name for failed messages
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry
queue.statsGET /v1/queue/stats/{queue}

Retrieve queue metrics: available, in-flight, and dead-lettered message counts.

参数 (1)
名称类型必填说明
queuestring必填Path parameter.
queue.updatePATCH /v1/queue/update/{queue}

Update a queue's DLQ, retry, and retention settings.

参数 (7)
名称类型必填说明
queuestring必填Path parameter.
dead_letter_queuestring | null可选Dead-letter queue name for failed messages
max_retriesinteger | null可选Maximum number of delivery retries
≥ 1
message_retention_daysinteger | null可选Number of days to retain queue messages
1–30
visibility_timeout_defaultinteger | null可选Default visibility timeout in seconds
0–43200
enable_priorityboolean | null可选Whether priority-based delivery is enabled
idempotency_keystring | null可选Client-provided idempotency key; prevents duplicate execution on retry

4. 完整示例

本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。

单文件可运行 Python 程序(仅标准库、无 SDK):拷贝后填入 INFRAI_API_KEY 运行,即可按真实业务流逐步体验本模块核心 API——每一步都真实调用并计费,后续步骤复用前一步返回的真实字段。12 行 helper 就是全部集成代码。

python
#!/usr/bin/env python3
"""Infrai · queue — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) queue.create — POST /v1/queue/create · Create a message queue (standard or FIFO, with optional dead-letter queue).
r1 = show("queue.create", infrai("POST", "/v1/queue/create", {"name":"jobs"}))

# 2) queue.publish — POST /v1/queue/publish · Publish a single message to a queue (idempotent).
r2 = show("queue.publish", infrai("POST", "/v1/queue/publish", {"queue":"jobs","payload":{"hello":"world"}}))

# 3) queue.consume — POST /v1/queue/consume · Pull a batch of messages from a queue for processing.
r3 = show("queue.consume", infrai("POST", "/v1/queue/consume", {"queue":"jobs","max_messages":1}))