Closed loupiz closed 5 years ago
Hi @loupiz,
There's none.
That could be something to be considered in a future release, but right now it doesn't add up to the main purpose of the application, which is to showcase the architectural patterns in a microservices application.
Hope this helps.
Hi,
I understand. I'm designing a microservices application (based on this project) and I need to make this kind of validation. A service needs to validate some data against data from another service. What I usually do is denormalizing but I can't do this this time because there is to much items. Using messages is not suitable either because validation needs to be synchronous.
Can I ask you how you would manage that ?
Thanks
Hi @loupiz,
My first question would be, Do you really need a microservices architecture for your app?
Microservices add significant complexity, as you're starting to realize, and that complexity has to be justified on the base of business needs, like scalability or handling a large number of independent development teams.
If a service NEEDS to synchronously validate with data from another service, that could just be a sign of an architectural issue, that could have several solutions, such as:
So it's an "it depends" answer as usual, but if you're having this kind of doubts now, perhaps you should consider a modular, well-architected, monolith application, with a clustered database if needed.
Have you read the Microservices guide that goes along with this repo?
Thanks for your answer.
Yes I did read the guide. I think we are really close to our goal and our last question is how to manage one validation. Very similar to validating the unit price when a user posts the CustomerBasket in eShopOnContainers (or later in the workflow like processing the order). That's why I was really interested of how you would manage it in eShopOnContainers.
Well, I don't know the context, so this may not apply, but I just wouldn't validate the price.
The basket has the "current" price, that gets updated through an integration event, every time the item price in the catalog changes.
If it were acceptable to cancel an in-process order, then the validation could be done in the ordering background microservice, that does some validations.
Hope this helps.
Thanks again. You say you wouldn't validate the price but how would you prevent a third party app to check out a basket with an item with a wrong price ? It would not be updated through the integration event if the price doesn't change. So the order could be processed and paid with a bad unit price. Am I wrong or do I miss something?
Well, that's why context is important!
If there's a third party app involved (which is not the case for eShopOnContainers) then I'd validate that while handling the CreateOrderCommand, adding the necessary notification mechanism, of course.
Hope this helps.
I'm closing this issue now, as it's not related to eShopOnContainers.
@mvelosop want to know why we have so many parameters on CreateOrderCommand method but not create a model for this method
public CreateOrderCommand(List<BasketItem> basketItems, string userId, string userName, string city, string street, string state, string country, string zipcode, string cardNumber, string cardHolderName, DateTime cardExpiration, string cardSecurityNumber, int cardTypeId) : this() { _orderItems = basketItems.ToOrderItemsDTO().ToList(); UserId = userId; UserName = userName; City = city; Street = street; State = state; Country = country; ZipCode = zipcode; CardNumber = cardNumber; CardHolderName = cardHolderName; CardExpiration = cardExpiration; CardSecurityNumber = cardSecurityNumber; CardTypeId = cardTypeId; CardExpiration = cardExpiration; }
Hi @goalbased, could you elaborate please? I don't get your doubt.
I've been looking through all the code but could not find any validation between basket item unit price and catalog item unit price.