Skip to content

Unify Kafka messages payloads #472

Open
@maxceem

Description

@maxceem

Since V5 we have unified Kafka topics to always have the next format:

  • project.action.create
  • project.action.update
  • project.action.delete

So far the payload which we send for each of the topics is not unified, but in most cases the payload looks like this:

"payload": {
   "resource": "project.template" // the name of "resource", one of https://github.com/topcoder-platform/tc-project-service/blob/feature/restful-invites/src/constants.js#L326-L347

   // other properties of the object
   "id": 1234,
   "name": "Name of project template",
   "key": "app",
   "createdAt": 1,
   "createdBy": 1,
   "updatedAt": 1,
   "updatedBy": 1,
}

As we want to stop sending specific Kafka events to TC Notification Service we would like to use these general V5 Kafka events instead, for generating notifications.

Though, to be able to generate some notification we have to know the object data before update and after update. So far it's handled inside Project Service using App Events, see:

So we have to update Kafka messages payload to include both original and updated object in project.action.update Kafka topic payloads.

I propose to use the next unified rules for all 3 topics:

{
  "topic": "project.action.update",
  "payload": {
     "resource": "project.template" // the name of resource, same like now
     "data": { ... } // updated object
     "previousData": {} // previous object
   }
{
  "topic": "project.action.create",
  "payload": {
     "resource": "project.template" // the name of resource, same like now
     "data": { ... } // created object
   }
{
  "topic": "project.action.delete",
  "payload": {
     "resource": "project.template" // the name of resource, same like now
     "data": { ... } // deleted object
   }

It was clarified during V5 migration, that we can format the payload as we need:

image

Note, that we would have to update project-processor-es and legacy-project-processor to consume Kafka messages in this new unified format, though I don't think any problems with this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions