i implementing event-driven microservice architecture. imagine following scenario:
- chat service: ability see conversations , send messages. conversations can have multiple participants.
- registration-login service: deals registration of new users, , login.
- user service: getting/updating user profiles.
the registration-login service emits following event newly created user object: registration-new
login-success
logout-success
the chat service listens on registration-new
, stores fields of user in own redis cache. listens on login-success
, stores token, , on logout-success
delete token.
the user service has following event: user-updated
. when fired, listener in chat service updates data corresponding user id in redis. chat service, user service listens on login-success
, logout-success
, same thing chat service does.
my question following: way this? feels bit counterintuitive sharing data everywhere. need advice on this. thank you!
seems there's no other way. microservices architecture puts lots of stress in avoiding data sharing not create dependencies. means each microservice have data duplicated. means there must exist way of getting data other contexts. preferred methods strive eventual consistency, such sending messages event sourcing or amqp systems , subscribing them. can use synchronous methods (rpc calls, distributed transactions). creates additional technologic dependencies, if cannot accept eventual consistency way.
Comments
Post a Comment