添加绑定
功能介绍
添加绑定。
URI
POST /v2/rabbitmq/{project_id}/instances/{instance_id}/vhosts/{vhost}/exchanges/{exchange}/binding
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| project_id | 是 | String | 项目ID,获取方式请参见获取项目ID。 |
| instance_id | 是 | String | 实例ID |
| vhost | 是 | String | vhost名称,名称中包含/时,需要将/替换为__F_SLASH__,否则会调用失败。例如:Vhost名称为/test,入参值为__F_SLASH__test。 |
| exchange | 是 | String | Exchange名称 |
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| destination | 是 | String | 要投递的Exchange或Queue名称 |
| routing_key | 是 | String | 参数解释: 绑定键值,用于告知Exchange应该将消息投递到哪些Queue或Exchange中。 约束限制:
取值范围: 不涉及。 默认取值: 不涉及。 |
| destination_type | 是 | String | 参数解释: 绑定目标端类型。 约束限制: 不涉及。 取值范围:
默认取值: 不涉及。 |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| source | String | 绑定对象 |
| destination_type | String | 参数解释: 绑定目标端类型。 取值范围:
|
| destination | String | 要投递的Exchange或Queue名称 |
| routing_key | String | 绑定键值,用于告知Exchange应该将消息投递到哪些Queue中 |
请求示例
将test-exchange作为源端,与目标端为Queue类型的mirror-queue绑定,绑定路由键为routing_key_1。
POST /v2/rabbitmq/{project_id}/instances/{instance_id}/vhosts/default/exchanges/test-exchange/binding
{
"destination_type" : "Queue",
"destination" : "mirror-queue",
"routing_key" : "routing_key_1"
} 响应示例
状态码:200
添加绑定成功
{
"source" : "exchange_name",
"destination_type" : "Queue",
"destination" : "queue_name",
"routing_key" : "binding_key_demo"
} 状态码
| 状态码 | 描述 |
|---|---|
| 200 | 添加绑定成功 |
错误码
请参见错误码。