Task №4 (designing integration in the MS architecture) You are a system analyst for the Legal Entity Account Opening system. 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). The reservation service returned a technical error. What requirements, as a system analyst for the Legal Entity Account Opening, would you present to the Contract and Reservation functional parts? Options for implementing the integration scenario, considering a distributed microservice architecture. (Sequence diagram "Opening a current account for a legal entity" with interaction steps between the Client, Web application, Legal Entity Account Opening Orchestrator, Contract functional part, and Account Reservation functional part)
sobes.tech AI
Answer from AI
In the described situation, where opening an account creates a contract, but account reservation fails, it is necessary to ensure data consistency and proper error handling in a distributed microservices architecture.
Contract Functional Requirements:
- Support for transactional integrity or compensating operations (e.g., canceling the created contract upon reservation failure).
- Ability to rollback changes (delete or annul the contract) upon request from the orchestrator.
- Idempotency of contract creation operations to avoid duplication on repeated calls.
Reservation Functional Requirements:
- Clear error handling with informative codes and messages.
- Ability to retry the reservation operation without negative consequences (idempotency).
Integration scenario implementation options:
-
Orchestration with compensating transactions (SAGA):
- The orchestrator calls contract creation.
- Upon successful contract creation, it calls account reservation.
- If reservation fails, the orchestrator initiates a compensating operation — contract cancellation.
-
Use of queues and events (Event-driven):
- Contract creation and account reservation are performed as separate events.
- On reservation error, a contract cancellation event is published.
-
Idempotent operations and retries:
- The orchestrator repeats the reservation call with state control.
- In case of prolonged error, compensation is initiated.
The sequence diagram should reflect these steps, showing calls from the client to the web application, then to the orchestrator, which sequentially interacts with the Contract Functional Module and the Reservation Functional Module, handling errors and performing compensations.