-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't find an example with CleanupFailedCartRequest #169
Comments
Hi again 😄 and thanks for having waited for me.
In this specific sample, there isn't really any scenario that comes to my mind that can lead to a failed request. That's the main reason that leads me to entirely remove the whole In summary, the previous approach on HTTP requests, and when in need of adding a new item to the cart the gateway had to orchestrate across 3 different outgoing POST requests, each one to a different service. If something goes badly in such a scenario there is no way for the gateway to make sure all requests are rolled back. HTTP does not provide (luckily) any transaction support. all-our-aggregates-are-wrong-demos/src/Sales.ViewModelComposition/ShoppingCartAddPostHandler.cs Lines 33 to 53 in 8b8b3ca
This means that one incoming HTTP request maps to one ongoing queue operation. And this is fine, if something goes badly at any level we can compensate. Once the message-to-self is processed it's handled by all the interested parties. For example, this is the Sales implementation: Lines 8 to 20 in 8b8b3ca
(you can find in the repo similar implementations for all the interested services) Now, the interesting change is that we're now dealing with an incoming message that needs to be translated into multiple outgoing messages. If something goes badly when sending one of the messages, the incoming message is retried until all the outgoing messages are successfully sent. The only downside to this is that in case of partial failure it leads to message duplication, but message deduplication can be solved at the receiver level by using the outbox pattern. (The outbox pattern is not implemented in this demo as it's outside the scope of the demo/talk.) Is there any downside in moving away from HTTP to messaging? Sure, it's always a tradeoff. In this case:
|
Can you pls show how to compensate in case on of the handlers fail to process the request? What would be the valid reason to fail? business exception? Request contains invalid data? Or should we strive to make sure our command is valid in 99% and dont perform any compensation requests?
The text was updated successfully, but these errors were encountered: