...
- Environment name (from ENV environment variable)
- Tenant name id (should be the second, because it is convenient to use wildcard in ACL for Kafka users)
- Producer module name ("storage" postfix should be omitted)
- Domain entity name in singular form (if it is not domain event, the name of process should be used or just event name)
...
bugfest.fs09000000.inventory.instance
Topic partitioning
In order not to have problems with consistency, that can occur due to race condition in case of concurrent writes to database Kafka topics should have appropriate partition_key. It could be id of the record or some another value, that allow to segregate events between consumer instances.
When multiple instances of the consumer modules are deployed, the same consumer group should be set for all of them.
Domain events json schema
Module sends notifications, when there is any change of domain entities (e.g. instance, holding, item, loans).
The pattern means that every time when an entity is created/updated/removed a message is posted to Kafka topic:
The event payload should have the following structure:
{ "old": {...}, // the entity state before update or delete "new": {...}, // the entity state update or create "type": "UPDATE|DELETE|CREATE|DELETE_ALL", // type of the event "tenant": "diku" // tenant name }
X-Okapi-Url
and X-Okapi-Tenant
headers could be set from the request to the Kafka message.
Domain events for delete all APIs
In order to clean data for some tenant. There could be delete all APIs for records. For such APIs we're issuing a special domain event:
- Partition key:
00000000-0000-0000-0000-000000000000
- Event payload:
{ "type": "DELETE_ALL", "tenant": "<the tenant name>" }