服务总线的 Azure 事件网格事件架构Azure Event Grid event schema for Service Bus

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

有关示例脚本和教程的列表,请参阅服务总线事件源For a list of sample scripts and tutorials, see Service Bus event source.

可用事件类型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.

示例事件Example event

以下示例显示了没有侦听器事件的活动消息的架构:The following example shows the schema of active messages with no listeners event:

[{
  "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"
}]

死信队列事件的架构类似:The schema for a dead letter queue event is similar:

[{
  "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"
}]

事件属性Event properties

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

属性Property 类型Type 说明Description
主题topic 字符串string 事件源的完整资源路径。Full resource path to the event source. 此字段不可写入。This field is not writeable. 事件网格提供此值。Event Grid provides this value.
subjectsubject 字符串string 事件主题的发布者定义路径。Publisher-defined path to the event subject.
eventTypeeventType 字符串string 此事件源的一个注册事件类型。One of the registered event types for this event source.
EventTimeeventTime 字符串string 基于提供程序 UTC 时间的事件生成时间。The time the event is generated based on the provider's UTC time.
idid 字符串string 事件的唯一标识符。Unique identifier for the event.
数据data objectobject Blob 存储事件数据。Blob storage event data.
dataVersiondataVersion 字符串string 数据对象的架构版本。The schema version of the data object. 发布者定义架构版本。The publisher defines the schema version.
metadataVersionmetadataVersion 字符串string 事件元数据的架构版本。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
namespaceNamenamespaceName 字符串string 资源所在的服务总线命名空间。The Service Bus namespace the resource exists in.
requestUrirequestUri 字符串string 发出此事件的特定队列或订阅的 URI。The URI to the specific queue or subscription emitting the event.
entityTypeentityType 字符串string 发出事件的服务总线实体的类型(队列或订阅)。The type of Service Bus entity emitting events (queue or subscription).
queueNamequeueName 字符串string 如果订阅队列,则为包含活动消息的队列。The queue with active messages if subscribing to a queue. 如果使用主题 / 订阅,则为值 null。Value null if using topics / subscriptions.
topicNametopicName 字符串string 包含活动消息的服务总线订阅所属的主题。The topic the Service Bus subscription with active messages belongs to. 如果使用队列,则值为 null。Value null if using a queue.
subscriptionNamesubscriptionName 字符串string 包含活动消息的服务总线订阅。The Service Bus subscription with active messages. 如果使用队列,则值为 null。Value null if using a queue.

后续步骤Next steps