RabbitMQ 绑定规范

Detailed documentation on the RabbitMQ binding component

配置

To setup RabbitMQ binding create a component of type bindings.rabbitmq. 请参阅本指南,了解如何创建和应用绑定配置。

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: bindings.rabbitmq
  8. version: v1
  9. metadata:
  10. - name: queueName
  11. value: queue1
  12. - name: host
  13. value: amqp://[username][:password]@host.domain[:port]
  14. - name: durable
  15. value: true
  16. - name: deleteWhenUnused
  17. value: false
  18. - name: ttlInSeconds
  19. value: 60
  20. - name: prefetchCount
  21. value: 0
  22. - name: exclusive
  23. value: false
  24. - name: maxPriority
  25. value: 5

Warning

以上示例将 Secret 明文存储。 更推荐的方式是使用 Secret 组件, 这里

元数据字段规范

字段必填绑定支持详情示例
queueNameYInput/OutputThe RabbitMQ queue name“myqueue”
hostYInput/OutputThe RabbitMQ host address“amqp://[username][:password]@host.domain[:port]”
durableNOutputTells RabbitMQ to persist message in storage. 默认值为 “false”“true”, “false”
deleteWhenUnusedNInput/OutputEnables or disables auto-delete. 默认值为 “false”“true”, “false”
ttlInsecondsNOutputSet the default message time to live at RabbitMQ queue level. 如果此参数为空,消息将不会过期,继续在队列上存在,直到处理完毕。 See also60
prefetchCountN输入Set the Channel Prefetch Setting (QoS). 如果此参数为空,QOS 会设置为0为无限制。0
exclusiveNInput/OutputDetermines whether the topic will be an exclusive topic or not. 默认值为 “false”“true”, “false”
maxPriorityNInput/OutputParameter to set the priority queue. 如果此参数为空,消息将不会过期,继续在队列上存在,直到处理完毕。 Value between 1 and 255. See also“1”, “10”

绑定支持

此组件支持 输入和输出 绑定接口。

该组件支持输出绑定,其操作如下:

  • create

输出绑定支持的操作

可以在队列级别 ( 如上所述) 或消息级别定义生存时间。 在消息级别定义的值会覆盖在队列级别设置的任何值。

若要设置在消息级别生存的时间,请使用 metadata 请求正文中的元数据部分。

字段名为 ttlInSeconds

示例:

  1. curl -X POST http://localhost:3500/v1.0/bindings/myRabbitMQ \
  2. -H "Content-Type: application/json" \
  3. -d "{
  4. \"data\": {
  5. \"message\": \"Hi\"
  6. },
  7. \"metadata\": {
  8. \"ttlInSeconds\": "60"
  9. },
  10. \"operation\": \"create\"
  11. }"
  1. curl -X POST http://localhost:3500/v1.0/bindings/myRabbitMQ \
  2. -H "Content-Type: application/json" \
  3. -d '{
  4. "data": {
  5. "message": "Hi"
  6. },
  7. "metadata": {
  8. "ttlInSeconds": "60"
  9. },
  10. "operation": "create"
  11. }'

相关链接

Priority can be defined at the message level. If maxPriority parameter is set, high priority messages will have priority over other low priority messages.

To set priority at message level use the metadata section in the request body during the binding invocation.

The field name is priority.

示例:

  1. curl -X POST http://localhost:3500/v1.0/bindings/myRabbitMQ \
  2. -H "Content-Type: application/json" \
  3. -d "{
  4. \"data\": {
  5. \"message\": \"Hi\"
  6. },
  7. \"metadata\": {
  8. "priority": \"5\"
  9. },
  10. \"operation\": \"create\"
  11. }"
  1. curl -X POST http://localhost:3500/v1.0/bindings/myRabbitMQ \
  2. -H "Content-Type: application/json" \
  3. -d '{
  4. "data": {
  5. "message": "Hi"
  6. },
  7. "metadata": {
  8. "priority": "5"
  9. },
  10. "operation": "create"
  11. }'

相关链接