Solution Architects supporting MicroServices based application development involve in various technical discussions including the application of Domain-Driven Design (DDD), Design Patterns, Business Events management, and others.
During detailed design when it comes to Transaction Management, I think, they should build a culture in the team of thinking in (a) “Transnational Consistency” (b) “Eventual Consistency”
Transactional Consistency:
In pure Domain-Driven vocabulary, if a MicroService (“FoodOrderServiceImpl.java”, needs to create an Order and needs to check various business rules before persisting the data into the database. This service might need to save Order with one or more other Entities within the same “transaction boundary”. This way if any business rules fail then an exception is thrown without creating an Orde database record.
Eventual Consistency:
In this scenario, as expected by you, the Order record gets created without creating the associated or context entities in the same context. But such dependent entities get created eventually, that is why eventual consistency. It just publishes an event for further processing by another service.
While the above thinking might have already discussed through various Design Patterns, the main intent of this post is to highlight the “Transactional Thinking” by the MicroServices team.