-
Notifications
You must be signed in to change notification settings - Fork 20
Notification
Notification is how changes in one domain / system / application are communicated out to (and therefore acted upon by) other domains / systems / applications.
In this system there are two types of thing that we can raise notifications about : a new entity is created and a new event is appended to the event stream of an existing entity.
A notification only says "this happened" and doesn't say what should be done with the thing that has happened. For that reason I am not passing state information in the notification.
A notification needs to indicate what it happened to. In this library that is done by the combination of Domain, Entity Type and Entity Instance Identifier.
For an event being appended to the event stream of an existing entity also needs to know the "as of" (when) of the event - which we send as the sequence number of the Event Stream
Notifications are sent via Azure Event Grid.
When a new entity (or [event stream]) is created a message like the following will be sent:
[
{
"id": "170259dc-aa00-47c1-855e-0052e35db99d",
"subject": "eventsourcing/Domain Test/Entity Type Test Two/Instance 1234",
"data": {
"notificationId": "2176282c2eab4982a22db5bfa2dc71ba",
"domainName": "Domain Test",
"entityTypeName": "Entity Type Test Two",
"instanceKey": "Instance 1234",
"commentary": ""
},
"eventType": "eventsourcing.NewEntity",
"eventTime": "2019-09-22T20:02:19.4710404Z",
"dataVersion": "1.0",
"metadataVersion": "1",
"topic": "/subscriptions/nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn/resourceGroups/CQRS/providers/Microsoft.EventGrid/topics/eventstream-notifications"
}
]
Whenever a new event is appended to an existing entity ([event stream]) a message like the following will be sent:-
[
{
"id": "2cedc82c-521d-45d3-a749-c552955bbdb5",
"subject": "eventsourcing/Domain Test/Entity Type Test Two/Event Happened/Instance 1234",
"data": {
"notificationId": "df302daa8d1947859766bf71026fd8da",
"domainName": "Domain Test",
"entityTypeName": "Entity Type Test Two",
"instanceKey": "Instance 1234",
"commentary": "",
"eventType": "Event Happened",
"sequenceNumber": 2023
},
"eventType": "eventsourcing.EventAppended",
"eventTime": "2019-09-22T20:02:19.6236918Z",
"dataVersion": "1.0",
"metadataVersion": "1",
"topic": "/subscriptions/nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn/resourceGroups/CQRS/providers/Microsoft.EventGrid/topics/eventstream-notifications"
}
]
The subject part is useful to allow event grid filtering so that subscribers can be notified only for specific new entities of a particular type or for specific event types being appended to the [event stream], rather than having to subscribe to all notifications and have the filtering performed internally.
The following application settings control if / how notifications are sent out from the event sourcing back end:
- RaiseEntityCreationNotification - set to "true" to send out notifications when a new [event stream] is created
- RaiseEventNotification - set to "true" to send out a notification when an event is appended to the [event stream]
- EventGridTopicEndpoint - The event grid endpoint to which the notifications will be sent
- EventGridKeyValue - The SAS token to use to authenticate to that event grid topic end point