存储与消息
RabbitMQ 生产者
type toRabbitmq
发送 RabbitMQ 消息,autoDeclare=true
使用说明
要点:发送 RabbitMQ 消息,固定 autoDeclare=true;exchangeType 支持 direct / topic / fanout / headers。
属性
| 字段 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
exchangeName交换机 |
文本 | 必填 | — | |
exchangeType交换机类型 |
枚举 | 必填 | topic |
|
routingKey路由键 |
文本 | 可选 | — | |
queues队列 |
文本 | 可选 | — |
示例流程
可直接保存为 demo-toRabbitmq.json 并部署;非入口节点默认套了一个 REST 入口。
{
"id": "demo-toRabbitmq",
"desc": "RabbitMQ 生产者 示例",
"group": "示例/存储与消息",
"schemaVersion": 1,
"nodes": [
{
"id": "n1",
"type": "rest",
"props": {
"method": "POST",
"path": "/demo/toRabbitmq",
"desc": "示例入口"
}
},
{
"type": "toRabbitmq",
"props": {
"exchangeName": "demo.exchange",
"exchangeType": "direct",
"routingKey": "demo.key",
"queues": "demo.queue"
},
"id": "n1"
}
]
}
curl -X POST 'http://localhost:8086/flow' \
-H 'Content-Type: application/json' \
-H 'X-Flow-Token: change-me' \
--data-binary @demo-toRabbitmq.json
调用方式
curl -X POST 'http://localhost:8086/demo/toRabbitmq' \
-H 'Content-Type: application/json' \
-d '{"message":"hello"}'