Middle+
You are a system analyst for the Corporate Account Opening system for legal entities. A task has been received from the business customer: to implement an account opening service. The account opening service includes creating a contract and reserving an account. When opening an account, the client's contract was successfully created (saved in the database), but the reservation service returned a technical error. What requirements, as an analyst for the Corporate Account Opening system for legal entities, would you present to the Contract Functional Part (FP) and Reservation FP? Consider options for implementing an integration scenario, taking into account a distributed microservice architecture.
sobes.tech AI
Answer from AI
In a distributed microservices architecture, when implementing an account opening service with two key operations — contract creation and account reservation — it is necessary to consider consistency and error handling issues.
Contract Functional Requirements:
- Ensure atomicity of the contract creation operation from the perspective of the local database (transaction).
- Provide the ability to rollback or compensate in case of errors in subsequent steps (e.g., if account reservation fails).
- Log the status of contract creation and the result of interaction with the reservation service.
Reservation Functional Requirements:
- Ensure idempotency of account reservation operations.
- Return detailed errors with codes and descriptions for proper handling.
- Support compensation (cancellation of reservation) in case of rollback.
Implementation options for the integration scenario:
-
Orchestration using saga:
- The account opening service initiates contract creation.
- After successful contract creation, the reservation service is called.
- If reservation fails, a compensating transaction is triggered — deleting or canceling the contract.
- This approach requires implementing a saga mechanism and state management.
-
Choreography via events:
- The contract creation service publishes a "Contract Created" event.
- The reservation service subscribes to this event and attempts to reserve the account.
- In case of an error, the reservation service publishes an "Reservation Error" event.
- The contract service reacts to this event, performing compensating actions.
-
Two-phase commit (2PC) transactions:
- Rarely used in distributed systems due to complexity and performance issues, but possible with support.
-
Using queues and retries:
- On reservation error, the request is placed in a queue for reprocessing.
- If after several attempts the error persists, compensation is initiated.
Ultimately, as an analyst, it is necessary to clearly define requirements for error handling, idempotency, compensation, and logging, and to coordinate with implementation teams on the integration approach (saga, events, queues).