跳到主要内容
版本:Next
input/amqp09INPUTBUFFERPROCESSOROUTPUT

AMQP 0.9 (RabbitMQ)

AMQP 0.9 输入(Input)从 RabbitMQ 等 AMQP 0.9/0.9.1 消息代理消费消息。作为通道型输入,它遵循引擎的取消安全契约:取消一次未完成的 read 不会丢失已解码的消息(参见输入投递语义)。

配置​

FieldTypeRequiredDefault描述
typestringyes—常量值 "amqp09"
urlstringyes—AMQP 代理 URL,例如 amqp://guest:guest@localhost:5672/%2f 或 amqps://...
queuestringyes—要消费的队列名称
exchangestringno—可选的交换机名称;配置后会将 queue 绑定到该交换机
exchange_typestringnodirect声明交换机时的类型(direct、fanout、topic、headers)
routing_keystringno""将 queue 绑定到 exchange 时使用的路由键
declare_queuebooleannofalse队列不存在时是否自动声明
declare_exchangebooleannofalse交换机不存在时是否自动声明(要求 exchange 非空)
durablebooleannotrue声明的交换机/队列是否持久化
auto_deletebooleannofalse声明的交换机/队列在无使用时是否自动删除
exclusivebooleannofalse声明的队列是否仅限当前连接独占
consumer_tagstringno""消费者标签(留空由代理自动分配)
auto_ackbooleannofalse收到消息后是否自动确认;为 false 时在下游处理完成后再发送 basic.ack
prefetch_countintegerno256单通道未确认在途投递数 QoS 限制(0–65535;不限制代理队列中等待的消息数)。默认 256,0 表示无限制;当 auto_ack 为 true 时此限制不生效

示例​

Topic 交换机与手动确认​

input:
type: "amqp09"
url: "amqp://guest:guest@localhost:5672/%2f"
queue: "orders-in"
exchange: "orders"
exchange_type: "topic"
routing_key: "orders.#"
declare_exchange: true
declare_queue: true
durable: true
auto_ack: false
prefetch_count: 64

Fanout 交换机​

input:
type: "amqp09"
url: "amqp://guest:guest@localhost:5672/%2f"
queue: "audit-log"
exchange: "events-fanout"
exchange_type: "fanout"
declare_exchange: true
declare_queue: true

TLS​

使用 amqps:// URL scheme 以 TLS 连接(例如 amqps://user:pass@broker.example.com:5671/%2f);客户端通过 rustls 与系统根证书原生协商 TLS。

读取错误​

当 AMQP 消费流异常中断或出现投递错误时,输入组件会上报 Disconnection 以触发引擎重连,而不会以 EOF 结束整个作业。