ADR Consumer Topic Identification [ Replay Design ]
ADR Consumer Topic Identification
Status
-
Proposed -
Trialing -
Under review -
Approved -
Retired
Problem Context
Today, the storage service publishes RecordChange messages to “recordstopic”.
When Storage Service publishes a RecordChange message to the “recordstopic” topic of the service bus, all the consumers get notified (eg. Indexer service, notification service). During scenarios like replaying for reindex scenarios, notifying all the consumers may not be required. Hence, we need a way to instruct storage service to publish RecordChange messages to a custom topic depending on the use case. For example, if the replay is going to be done for re-index, then we can instruct storage service to publish the RecordChange messages to a “reindex” topic which is being listened to by the indexer only, instead of publishing them to recordstopic which has many consumers. This will ensure that only the indexer service gets notified of the events.
Therefore, it is of utmost importance that the Producer's design allows for the appropriate routing of operations to their intended topics. This brings us to the question of how the Storage service can accurately determine the topic to which each message should be directed based on its specific functionality/operation . In response to this challenge, we have explored the following design, which will serve as the foundation for the development of our Replay API.
Design Option | Detailed Approach | Pros/Cons |
[Preferred Approach] |
There will be a separate topic for each operation.
For example, indexer service can listen to a topic called “reindex” and notification service can listen to the topic “notify” in addition to “recordstopic”. The replay API will take the input as operation name i.e. reindex, based on that, it will decide which topic the replay API has to publish the recordChange message. This will ensure only the indexer gets notified. Note – One operation will maps to one Topic in Service ( 1:1) . While a single topic can have multiple consumers. |
Pros:
|
|
There will be a separate topic for each operation.
For example, indexer service can listen to a topic called “reindex” and notification service can listen to the topic “notify” in addition to “recordstopic”. If Replay is required for reindex scenario, then replay API can be called with the parameter topicId’s value as “reindex”. This will cause storage services to publish recordChange messages to reindex topic instead of recordchangetopic. This will ensure only the indexer gets notified. |
Pros -
|
|
In this, a new Reindex API in indexer will call the replay API and will provide the topic name along in the request body. |
Pros –
|
Conclusion - We are going with approach 1 taking into consideration the Pros.