你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
将一批消息发送到服务总线队列或主题。
请求
| 方法 | 请求 URI | HTTP 版本 |
|---|---|---|
| 发布 | http{s}://{serviceNamespace}.servicebus.windows.net/{queuePath|topicPath}/messages|HTTP/1.1 |
请求标头
下表描述了必需和可选的请求标头。 除了列出的属性,标头还可以包含自定义属性。 请参阅示例。
| 请求标头 | 描述 |
|---|---|
| 授权 | 指定以下标记值之一:
|
| Content-Type | 设置为 应用程序/vnd.microsoft.servicebus.json。 |
| x-ms-retrypolicy | (可选)设置为 NoRetry 在发生暂时性错误时禁用发送作的自动重试。 |
请求正文
请求正文包含 JSON 编码的消息批处理。
响应
响应包括 HTTP 状态代码和一组响应标头。
响应代码
| 法典 | 描述 |
|---|---|
| 201 | 消息已成功发送到队列或主题。 |
| 400 | 请求错误。 |
| 401 | 授权失败。 |
| 403 | 超出配额或消息太大。 |
| 410 | 指定的队列或主题不存在。 |
| 500 | 内部错误。 |
有关状态代码的信息,请参阅 状态和错误代码。
响应标头
传入 内容类型。
响应正文
没有。
例
以下 HTTP 请求将一批三条消息发送到队列或主题。 第一条消息具有 TimeToLiveTimeSpan 值为 40 秒,第二条消息具有自定义消息属性“Priority”,第三条消息具有自定义消息属性“Priority”和“Customer”。
POST https://your-namespace.servicebus.windows.net/HttpClientSampleQueue/messages?timeout=60 HTTP/1.1
Authorization: SharedAccessSignature sr=your-namespace&sig=Fg8yUyR4MOmXfHfj55f5hY4jGb8x2Yc%2b3%2fULKZYxKZk%3d&se=1404256819&skn=RootManageSharedAccessKey
Content-Type: application/vnd.microsoft.servicebus.json
Host: your-namespace.servicebus.windows.net
Content-Length: 18
Expect: 100-continue
[
{
"Body":”This is the first message",
"BrokerProperties":{"Label":"M1","TimeToLiveTimeSpan":"0.00:00:40"}
},
{
"Body":”This is the second message",
"BrokerProperties":{"Label":"M2"},
"UserProperties":{"Priority":"Low"}
},
{
"Body":”This is the third message",
"BrokerProperties":{"Label":"M3"},
"UserProperties":{"Priority":"Medium","Customer":"ABC"}
}
]
服务总线返回以下响应:
HTTP/1.1 201 Created
Transfer-Encoding: chunked
Content-Type: application/xml; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 01 Jul 2014 23:00:22 GMT
0