Flow ServerStarter
存储与消息

RabbitMQ 生产者

type toRabbitmq

在设计器中打开 ↗

发送 RabbitMQ 消息,autoDeclare=true

使用说明

要点:发送 RabbitMQ 消息,固定 autoDeclare=true;exchangeType 支持 direct / topic / fanout / headers。
可选依赖该节点需要宿主额外引入 camel-spring-rabbitmq-starter,否则部署相关流程会在 Camel 启动路由阶段失败并回滚。

属性

字段类型必填默认值说明
exchangeName
交换机
文本 必填 —
exchangeType
交换机类型
枚举 必填 topic
可选值:direct、topic、fanout、headers
routingKey
路由键
文本 可选 —
queues
队列
文本 可选 —

示例流程

可直接保存为 demo-toRabbitmq.json 并部署;非入口节点默认套了一个 REST 入口。

Flow JSON
{
  "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"}'

相关节点