I have looked into this article and still i have some confusion regarding merging separate topics in one comprehensive topic: https://www.confluent.io/blog/put-several-event-types-kafka-topic
So i have two entities, Account & Client as given below:
Account:
"Account": {
"AccountId": "JKB123456",
"ClientId": "1234567",
"Type": "Savings",
"Currency": "USD"
}
Client:
"Client": {
"ClientId": "1234567",
"Name": "John Doe",
"PhoneNo": "777777777"
}
A Client can have at least one or more accounts associated with it. The events which will work on them ar pretty basic i.e. Create and Update.
This results in four use-cases:
- Create a client - A client entity with multiple Account entities are provided. If the client with all its account is created, the use-case is considered successfully executed.
- Update Client - A client (only) has some of its details updated, so a client object with the said values is provided. Account is not part of this.
- Create Account - An account entity is provided to be created and associated with an existing account.
- Update Account - An existing account fields can be updated in this use-case.
A create client json structure will look like this:
{
"Client": {
"ClientId": "1234567",
"Name": "John Doe",
"PhoneNo": "777777777",
"Accounts": [
{
"AccountId": "JKB123456",
"ClientId": "1234567",
"Type": "Savings",
"Currency": "USD"
},
{
"AccountId": "HKB123456",
"ClientId": "1234567",
"Type": "Savings",
"Currency": "EUR"
}
]
}
}
So should i have a single Client topic schema with list of account structure as part of it? I believe then i can publish both create and update events for the client on the same topic.
But would it be possible to publish the Account Create/update events on the same topic as well? Because i think if i do proper ordering (probably on the basis of clientid) then i can also have the all events of the same client on the same partition.
Do you think this is a good approach?