- Cloud-Native Applications in Java
- Ajay Mahajan Munish Kumar Gupta Shyam Sundar
- 359字
- 2021-06-24 19:07:23
Capabilities for microservices coordination
This section lists the capabilities that the composite services require:
- State management: Often the state manager component is required to manage the output state of the services that it is coordinating. This state will need to be held in a persistent store that is immune to server-side state management (SSM) failure. Another SSM instance should be able to retrieve the state and start where it left off.
- Transaction control: Transaction boundaries are affected by microservices. Two separate function calls to two methods in a single transaction now become two separate service calls through a composite service. There are two approaches to handle this scenario.
- Distributed transactions: These support the two-phase commit protocol. They are not scalable, increase latency and deadlocking scenarios, and need expensive products and infrastructure to support them. They may not be supported over selected protocols, such as REST or messaging. The benefit of this style is that the system is always in a consistent state.
- Compensating transactions: Where the transaction control is functionally enforced by running functionally reverse transactions instead of trying to roll back to an earlier transaction. This is a more decoupled, and hence scalable, approach.
We would recommend compensating transactions over distributed transactions due to simplification in the technical product requirements.
- Post service call coordination: Atomic service calls can result in success, that is, when the constituent services have finished their work successfully; or a failure, when either of the coordination services has either not responded or failed in processing due to a technical or functional error. The composite service will need to get the response of the completed services and decide on the next step of action.
- Timeout handling: Initiate a timer when starting a microflow. If the services do not respond in a particular time from starting the microflow, then raise an event to send to the event bus.
- Configurability: Multiple instances of the SSM component will run to cater for various microflows. In each of the microflows, the service coordination, timer, and actions will differ. Hence, it is important to provide a framework that can have parameterized configuration of the timers, compensation transactions, and post-processing actions.