Multiple EventTypes in Azure EventGrid Topic

2019-08-18 18:14发布

What is the best practices around Azure EventGrid topics and Events?

Is it a bad idea to publish different event-types to the same Azure EventGrid topic? e.g. multiple different domain events

When do we need different topics? A single shared Topic for an entire application? One Topic per Aggregate Root type? One Topic per Event Type?

Any suggestions would be welcome as there are no clear answers

Part2.

What if I want to integrate with various Azure Logic Apps? if multiple logic apps react to the same topic, would they steal messages from each-other? Do each logic app create some invisible subscription?

2条回答
Luminary・发光体
2楼-- · 2019-08-18 18:35

No, it is not a bad idea to publish different event-types to the same Azure EventGrid topic: if the events are related to the same resource, it does make sense to publish them to the same EventGrid topic. Taking the example of a HR application, you can have EmployeeAdded and EmployeeRemoved events published on the same "employee" topic.

On the question on when different topics would be needed, I think it depends on a few factors such as how you are modelling the resources in your application, the events of interest on those resources, security model around which parts of the system should be able to publish to the topic / creation of event subscriptions on the topic. Ideally, all types of events for the same resource type (such as the "employee" resource type in the example above) can be on the same topic. When your system has more types of resources, you may want to create separate topics for each of them. Also, the desired security model has to be taken into account as well (e.g. let's say you want to restrict access to who can receive certain types of events).

Regarding the question about logic apps, if you create multiple logic apps that handle events from the same topic, each of them creates an event subscription on the same topic, and Event Grid would deliver the events on that topic to each of the event subscriptions. So, each logic app would receive the same event individually, and can process it independent of the other apps.

查看更多
放荡不羁爱自由
3楼-- · 2019-08-18 18:53

The Azure Event Grid (AEG) is not a generic Pub/Sub model. This model is based on the source of the events, where each event source (topicType) is handling own interest.

Subscriber subscribes an interest to the event source (topic) using a subscription. Note, that the AEG allows to subscribe only one topic in the subscription. There is a limit 500 subscriptions per topic.

In other words, if there is a multiple interest for event source (topic) by the same subscriber, this model requires to create a multiple subscriptions (one per topic) per subscriber. The filtering of the interest is possible only within the same topic.

The source of events in the AEG can be extended by custom topics (maximum 100 per Azure Subscription).

Based on the above, I do recommend for custom topics use the same model like is built-in for azure event sources (topicTypes) with a multiple eventTypes, which can be simplified a continuously deployment over environments.

To the Part2: The AEG doesn't use an 'invisible' subscription as a part of the integration. Every subscription created to the topic is visible and accessable, for example using a REST API

Update:

Azure Event Grid recently release (in preview - version 2018-09-15-preview) a new feature which can be helped for your solution using an Event Domain and Domain Topics, more details here.

You can use an updated tool Azure Event Grid Tester for testing all new preview release features, which they are not yet implemented in the Azure portal UI.

查看更多
登录 后发表回答