jeudi 25 avril 2019

How to design a pub-sub system where there can be multiple publisher for same entity?

Consider the following situation:

  1. There is a User table with fields like name, email, contact_no etc.
  2. We have multiple products/system(with their own db) which use User information for various purpose.
  3. These systems remain in sync by pub-sub pattern eg: System 1 changes name is consumed by system 2 and make changes in system 2.
  4. For simplicity let us assume there are 3 systems:
    • S1 having UI for the user. Here user can himself change his information.
    • S2 system given to the sales person. Here user can call sales person and update their information.
    • S3 another product which uses information from S1 and S2 for various computations.

So information can be published from S1 and S2.

Suppose a user initially have name N1.

  • At time t1, user updates name from N1 to N2.
  • At time t1, sales person updates name from N1 to N3.

  • Now S1 consumes event from S3 and updates name to N3. S2 consumes event from S1 and updates name to N2.

  • In S3 name can be anything N2 OR N3 depending which event is consumed first.

This has caused a lot of data consistency among various system.

In ideal system there is only one publisher but due to requirement we had to add publishing events from Sales panel. What can be done to minimize data inconsitency?

Aucun commentaire:

Enregistrer un commentaire