如果使用第三方事件而不保证其按顺序处理,并且 webhook 有效负载是一个数组,则 Azure 事件网格可以直接使用您的第三方 webhook。 p>
下面的屏幕 sn-p 显示了这个例子:
上述集成基于 Custom Topic Endpoint 和 CustomInputSchema。
自定义主题端点使用以下 HTTP 响应代码将响应发送回 Webhook:
Success 200 OK
Event data has incorrect format 400 Bad Request
Invalid access key 401 Unauthorized
Incorrect endpoint 404 Not Found
Array or event exceeds size limits 413 Payload Too Large
AEG 模型以松散解耦的 Pub/Sub 方式分发事件,并根据其订阅向订阅者可靠地重试传递。 AEG 订阅代表了兴趣来源和消费者之间的逻辑连接。它是一组元数据,由消费者描述什么、在哪里以及如何。
基本上有两种交付模式,例如:
更新:
对于使用 CustomInputSchema 创建自定义主题端点,可以使用 REST API
以下是负载 PUT 请求的示例:
{
"location": "westus",
"properties": {
"inputSchema": "CustomEventSchema",
"inputSchemaMapping": {
"properties": {
"id": {
"sourceField": null
},
"topic": {
"sourceField": null
},
"eventTime": {
"sourceField": null
},
"eventType": {
"sourceField": null,
"defaultValue": "notification"
},
"subject": {
"sourceField": null,
"defaultValue": "/webhook/events"
},
"dataVersion": {
"sourceField": null,
"defaultValue": "1.0"
}
},
"inputSchemaMappingType": "Json"
}
}
}
上面的 CustomInputSchema 允许为此自定义主题端点使用任何输入事件模式。这是 AEG 的一个非常好的功能。 “坏消息”是事件必须在数组中也包含单个事件。我希望,当单个事件也可以作为 JObject(不在数组内部)发布时,AEG 团队将改进自定义和域主题。
对于通过 AEG 事件模型绕过输入事件模式,订阅者(源事件兴趣的消费者)必须声明一个 DeliverySchema = CustomInputSchema。默认输出事件架构是 EventGridSchema。
以下示例显示了使用上述 CustomInputSchema 发布到自定义主题并使用 CustomInptutSchema 传递给订阅者的事件消息,另一个使用 EventGridSchema .
向自定义主题端点触发事件(事件数组):
[
{
"abcd": 12345
}
]
订阅者 DeliverySchema = CustomInputSchema:
{
"abcd": 12345
}
订阅者 DeliverySchema = EventGridSchema(默认架构):
{
"id": "f92a5dbf-d206-4e61-ac1e-7498c543039a",
"eventTime": "2019-07-14T07:19:00.3969337Z",
"eventType": "notification",
"dataVersion": "1.0",
"metadataVersion": "1",
"topic": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rk2012/providers/Microsoft.EventGrid/topics/testerTopic8",
"subject": "/webhook/events",
"data":
{
"abcd": 12345
}
}
请注意,每个订阅者的事件可以是filtered(已选择),基于松散解耦的 Pub/Sub 方式的订阅属性。换句话说,订阅者可以随时通过声明特定源兴趣的订阅来订阅 AEG 事件模型,例如主题、主题、事件数据等、投递机制、重试、死信等。