Second approach
We can fetch the last logged-in time from the security service instead of storing that information in user-service. We can remove the lastLoggedInTime field from the user database. It means user-service won't store the last logged-in time information in it. Now, for this scenario, a call would be made to security-service to fetch the last logged-in time. Even if this call fails, it won't break the functionality.
The second approach is far better, as it makes the system more resilient by avoiding distributed transactions and having better handling of call failures.
There are many scenarios when you have to use distributed transactions. One such scenario is as follows.
Let's again talk about the OTRS app. The OTRS app allows ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access