通过多个微服务验证数据
我正在尝试了解如何使用Spring-boot开发和管理微服务。 在我的情况下,我正在管理一家餐厅及其订单,拥有产品列表和订单级折扣码。这些产品可以具有自己的价格折扣(餐厅的所有者可以将产品的折扣设置为True,甚至让整个订单中的折扣代码应用于折扣)。 关于我挣扎的部分是: 我应该如何管理该订单的验证?创建订单后,应该使用其他微服务来检查订单完成并有效进行处理。 这些步骤是:
- 创建的订单
- 验证产品及其价格,如果通过FE通过折现,则
- 验证折扣代码的存在,并将其应用于订单,
如果我创建了一个不同的组件,以接收创建的订单并异步验证它们(使用RabbitMQ)并从其他微服务中获取信息? 谢谢
I'm trying to understand how to develop and manage microservice using Spring-Boot.
In my situation I'm managing a Restaurant and its Orders, having a List of Products and a order-level DiscountCode. The Products can have their own priced discounted (the owner of the restaurant can set as true the discountedPrice of the product and even let apply the discountcode for the entire order).
The part on what i am struggling on is the following:
How should I manage the validation for the Order? When an order has been created it should check using the other micro-services to make the order completed and valid to be processed.
The steps are:
- Order created
- Verify the products and its price and if they are discounted as passed by the FE
- Verify the existence of the discountCode and apply it to the order
Should I create a different component that receives the order created and validate them asynchronously (using RabbitMQ) and getting the information from the other microservices?
Thanks in advice
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个棘手的问题,因为我们没有确定域名和现有服务。
每项服务都应因其自身验证而受到责任。要检查折扣是否有效,我希望折扣服务应进行验证。
如果它与订单服务相同,则订单服务应恢复对象并在获得价格后进行验证。
但这取决于您和您的领域。
That's a difficult question, because we did not knwo the domain and the existing services.
Each service should be responible for its own validation. To check if the discount is valid I would prefer that the Discount-Service should do the validation.
If it is same as the order service, the order service should get back the object and validate it after getting the prices.
But it's up to you and your domain.