充当事件网格源的 Azure 服务总线Azure Service Bus as an Event Grid source

本文提供了服务总线事件的属性和架构。This article provides the properties and schema for Service Bus events.  有关事件架构的简介,请参阅 Azure 事件网格事件架构For an introduction to event schemas, see Azure Event Grid event schema.

可用事件类型Available event types

服务总线发出以下事件类型:Service Bus emits the following event types:

事件类型Event type 说明Description
Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListenersMicrosoft.ServiceBus.ActiveMessagesAvailableWithNoListeners 当队列或订阅中存在活动消息,但却没有接收器在侦听时会引发此事件。Raised when there are active messages in a Queue or Subscription and no receivers listening.
Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListenerMicrosoft.ServiceBus.DeadletterMessagesAvailableWithNoListener 当死信队列中存在活动消息,但却没有活动接收器时会引发此事件。Raised when there are active messages in a Dead Letter Queue and no active listeners.
Microsoft.ServiceBus.ActiveMessagesAvailablePeriodicNotificationsMicrosoft.ServiceBus.ActiveMessagesAvailablePeriodicNotifications 如果在队列或订阅中存在活动消息,即使该特定队列或订阅上有活动侦听器,也会定期引发此事件。Raised periodically if there are active messages in a Queue or Subscription, even if there are active listeners on that specific Queue or Subscription.
Microsoft.ServiceBus.DeadletterMessagesAvailablePeriodicNotificationsMicrosoft.ServiceBus.DeadletterMessagesAvailablePeriodicNotifications 如果队列或订阅的死信实体中存在消息,即使该特定队列或订阅的死信实体上有活动侦听器,也会定期引发此事件。Raised periodically if there are messages in the dead-letter entity of a Queue or Subscription, even if there are active listeners on the dead-letter entity of that specific Queue or Subscription.

示例事件Example event

没有侦听器时有活动消息可用Active messages available with no listeners

如果队列或订阅中存在活动的消息,但却没有接收器侦听,则会生成此事件。This event is generated if you have active messages in a queue or a subscription and there are no receivers listening.

[{
  "topic": "/subscriptions/{subscription-id}/resourcegroups/{your-rg}/providers/Microsoft.ServiceBus/namespaces/{your-service-bus-namespace}",
  "subject": "topics/{your-service-bus-topic}/subscriptions/{your-service-bus-subscription}",
  "eventType": "Microsoft.ServiceBus.ActiveMessagesAvailableWithNoListeners",
  "eventTime": "2018-02-14T05:12:53.4133526Z",
  "id": "dede87b0-3656-419c-acaf-70c95ddc60f5",
  "data": {
    "namespaceName": "YOUR SERVICE BUS NAMESPACE WILL SHOW HERE",
    "requestUri": "https://{your-service-bus-namespace}.servicebus.chinacloudapi.cn/{your-topic}/subscriptions/{your-service-bus-subscription}/messages/head",
    "entityType": "subscriber",
    "queueName": "QUEUE NAME IF QUEUE",
    "topicName": "TOPIC NAME IF TOPIC",
    "subscriptionName": "SUBSCRIPTION NAME"
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

没有侦听器时有死信消息可用Deadletter Messages Available With No Listener

死信队列事件的架构类似。The schema for a dead letter queue event is similar. 对于每个有消息但没有活动接收器的死信队列,你会至少收到一个事件。You get at least one event per dead-letter queue that has messages and no active receivers.

[{
  "topic": "/subscriptions/{subscription-id}/resourcegroups/{your-rg}/providers/Microsoft.ServiceBus/namespaces/{your-service-bus-namespace}",
  "subject": "topics/{your-service-bus-topic}/subscriptions/{your-service-bus-subscription}",
  "eventType": "Microsoft.ServiceBus.DeadletterMessagesAvailableWithNoListener",
  "eventTime": "2018-02-14T05:12:53.4133526Z",
  "id": "dede87b0-3656-419c-acaf-70c95ddc60f5",
  "data": {
    "namespaceName": "YOUR SERVICE BUS NAMESPACE WILL SHOW HERE",
    "requestUri": "https://{your-service-bus-namespace}.servicebus.chinacloudapi.cn/{your-topic}/subscriptions/{your-service-bus-subscription}/$deadletterqueue/messages/head",
    "entityType": "subscriber",
    "queueName": "QUEUE NAME IF QUEUE",
    "topicName": "TOPIC NAME IF TOPIC",
    "subscriptionName": "SUBSCRIPTION NAME"
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

活动消息可用定期通知Active Messages Available Periodic Notifications

如果在特定队列或订阅上具有活动消息,即使该特定队列或订阅上有活动侦听器,也会定期生成此事件。This event is generated periodically if you have active messages on the specific queue or subscription, even if there are active listeners on that specific queue or subscription.

[{
  "topic": "/subscriptions/<subscription id>/resourcegroups/DemoGroup/providers/Microsoft.ServiceBus/namespaces/<YOUR SERVICE BUS NAMESPACE WILL SHOW HERE>",
  "subject": "topics/<service bus topic>/subscriptions/<service bus subscription>",
  "eventType": "Microsoft.ServiceBus.ActiveMessagesAvailablePeriodicNotifications",
  "eventTime": "2018-02-14T05:12:53.4133526Z",
  "id": "dede87b0-3656-419c-acaf-70c95ddc60f5",
  "data": {
    "namespaceName": "YOUR SERVICE BUS NAMESPACE WILL SHOW HERE",
    "requestUri": "https://YOUR-SERVICE-BUS-NAMESPACE-WILL-SHOW-HERE.servicebus.chinacloudapi.cn/TOPIC-NAME/subscriptions/SUBSCRIPTIONNAME/$deadletterqueue/messages/head",
    "entityType": "subscriber",
    "queueName": "QUEUE NAME IF QUEUE",
    "topicName": "TOPIC NAME IF TOPIC",
    "subscriptionName": "SUBSCRIPTION NAME"
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

死信消息可用定期通知Deadletter Messages Available Periodic Notifications

如果在特定队列或订阅上具有死信消息,即使该特定队列或订阅的死信实体上有活动侦听器,也会定期生成此事件。This event is generated periodically if you have deadletter messages on the specific queue or subscription, even if there are active listeners on the deadletter entity of that specific queue or subscription.

[{
  "topic": "/subscriptions/<subscription id>/resourcegroups/DemoGroup/providers/Microsoft.ServiceBus/namespaces/<YOUR SERVICE BUS NAMESPACE WILL SHOW HERE>",
  "subject": "topics/<service bus topic>/subscriptions/<service bus subscription>",
  "eventType": "Microsoft.ServiceBus.DeadletterMessagesAvailablePeriodicNotifications",
  "eventTime": "2018-02-14T05:12:53.4133526Z",
  "id": "dede87b0-3656-419c-acaf-70c95ddc60f5",
  "data": {
    "namespaceName": "YOUR SERVICE BUS NAMESPACE WILL SHOW HERE",
    "requestUri": "https://YOUR-SERVICE-BUS-NAMESPACE-WILL-SHOW-HERE.servicebus.chinacloudapi.cn/TOPIC-NAME/subscriptions/SUBSCRIPTIONNAME/$deadletterqueue/messages/head",
    "entityType": "subscriber",
    "queueName": "QUEUE NAME IF QUEUE",
    "topicName": "TOPIC NAME IF TOPIC",
    "subscriptionName": "SUBSCRIPTION NAME"
  },
  "dataVersion": "1",
  "metadataVersion": "1"
}]

事件属性Event properties

事件具有以下顶级数据:An event has the following top-level data:

属性Property 类型Type 说明Description
topic stringstring 事件源的完整资源路径。Full resource path to the event source. 此字段不可写入。This field is not writeable. 事件网格提供此值。Event Grid provides this value.
subject stringstring 事件主题的发布者定义路径。Publisher-defined path to the event subject.
eventType stringstring 此事件源的一个注册事件类型。One of the registered event types for this event source.
eventTime stringstring 基于提供程序 UTC 时间的事件生成时间。The time the event is generated based on the provider's UTC time.
id 字符串string 事件的唯一标识符。Unique identifier for the event.
data 对象 (object)object Blob 存储事件数据。Blob storage event data.
dataVersion stringstring 数据对象的架构版本。The schema version of the data object. 发布者定义架构版本。The publisher defines the schema version.
metadataVersion stringstring 事件元数据的架构版本。The schema version of the event metadata. 事件网格定义顶级属性的架构。Event Grid defines the schema of the top-level properties. 事件网格提供此值。Event Grid provides this value.

数据对象具有以下属性:The data object has the following properties:

属性Property 类型Type 说明Description
namespaceName stringstring 资源所在的服务总线命名空间。The Service Bus namespace the resource exists in.
requestUri stringstring 发出此事件的特定队列或订阅的 URI。The URI to the specific queue or subscription emitting the event.
entityType stringstring 发出事件的服务总线实体的类型(队列或订阅)。The type of Service Bus entity emitting events (queue or subscription).
queueName stringstring 如果订阅队列,则为包含活动消息的队列。The queue with active messages if subscribing to a queue. 如果使用主题 / 订阅,则为值 null。Value null if using topics / subscriptions.
topicName stringstring 包含活动消息的服务总线订阅所属的主题。The topic the Service Bus subscription with active messages belongs to. 如果使用队列,则值为 null。Value null if using a queue.
subscriptionName stringstring 包含活动消息的服务总线订阅。The Service Bus subscription with active messages. 如果使用队列,则值为 null。Value null if using a queue.

教程和操作指南Tutorials and how-tos

标题Title 描述Description
教程:Azure 服务总线到 Azure 事件网格集成示例Tutorial: Azure Service Bus to Azure Event Grid integration examples 事件网格将消息从服务总线主题发送到函数应用和逻辑应用。Event Grid sends messages from Service Bus topic to function app and logic app.
Azure 服务总线到事件网格的集成Azure Service Bus to Event Grid integration 概述服务总线与事件网格的集成。Overview of integrating Service Bus with Event Grid.

后续步骤Next steps