0

I am trying to solve the following problem in a microservice architecture. I am very new to this architecture so let me know if I miss use some of the concepts.

Here is the problem I need to solve:

In an E-Commerce system, a user can place an order for some products. 15 days after the order creation, the system must send an e-mail to the client with a link to evaluate his satisfaction.

In order to solve the problem, and to not just come here asking for the best solution, I came with two different solutions:

First Solution: Link microservices with events traveling in an event bus.

enter image description here

Second Solution: Create a "Scheduler" service whose job is to listen on events and schedule tasks in the environment:

enter image description here

Question Conclusion:

I think Solution 2 is not that bad but I would love to hear experts about that architecture, am I doing it all wrong? Do I need to run in a bookstore because I don't get nothing out of microservices? Is their a third solution you see that could be better to solve the problem and respect microservices principles?

1

Both your solutions are basically the same, the first just has an internal scheduler.

You could equally well send the whole order to the reviews service in solution 1 rather than have it query the order service in 15 days.

The essential problem that neither solution addresses is cancelling the scheduled event after it's been set up.

Really it's a simple problem, have a second service which runs daily, queries all the orders that are 15 days old and haven't been processed yet from the orders service, sends the email and marks the order processed.

If something happens in the 15 day period that means the email shouldn't be sent, then change the query or the processing to fit the new requirement

The only wrinkle is implementing a lock of some kind to prevent the same order being processed at the same time by another instance of the service.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.