| NET-Core-10-New-Features :👈 | 👉:ASP.NET Interview Questions-6 |
Distributed Transaction Interview Questions & answers |
ASP.NET Core Distributed Transactions Interview Questions
Q1. What is a distributed transaction?
A business operation involving multiple independent services, databases, or systems.
Q2. What is the Saga Pattern?
A pattern that coordinates a distributed business transaction through a sequence of local transactions and compensating actions.
Q3. What is a compensating transaction?
A business operation that counteracts the effect of an earlier successful operation when a later step fails.
Q4. What are the two types of Saga?
Choreography-based Saga and orchestration-based Saga.
Q5. What is the difference between choreography and orchestration?
Choreography relies on services reacting to events without a central coordinator. Orchestration uses a central Saga component to manage the workflow.
Q6. What is the Outbox Pattern?
It stores a business data change and its outgoing event record in the same local database transaction. A background process publishes the event afterward.
Q7. What is the dual write problem?
It occurs when an application writes to a database and publishes to a message broker as separate operations. One can succeed while the other fails.
Q8. Does the Outbox Pattern guarantee exactly-once message delivery?
No. It generally provides at-least-once publication. Consumers must handle duplicate delivery using idempotency.
Q9. How does Saga handle failures?
It executes compensating transactions for previously completed steps according to the business workflow.
Q10. Can Saga and Outbox be used together?
Yes. Saga coordinates the business workflow, while Outbox reliably records and publishes messages from each participating service.
Q11. What is the difference between Saga and 2PC?
2PC coordinates a distributed commit using transaction participants. Saga uses independent local transactions and business compensations without requiring one global atomic transaction.
Q12. What happens if a Saga service crashes?
A persistent Saga state allows the workflow to resume or recover after restart. Message redelivery and idempotent processing are also important.
Q13. What is a dead-letter queue?
A queue where messages are placed after they cannot be processed successfully under the configured retry and error-handling policy.
Q14. Why is idempotency important in microservices?
Because message brokers and retry mechanisms can deliver the same message more than once. Idempotency prevents duplicate business effects.
Q15. Can an external payment API participate in a SQL transaction?
Usually not. The payment operation is handled as an independent step in the Saga. If a later step fails after payment succeeds, the application may need to issue a refund or void operation.
Q16. What is the difference between an Outbox and an Inbox?
Outbox stores outgoing messages that need to be published. Inbox stores or tracks incoming messages to support deduplication and reliable processing.
Q17. What is the purpose of correlation ID?
It links related logs, messages, and service operations to help trace one distributed business workflow.
Q18. What is the role of MassTransit?
MassTransit provides .NET abstractions for messaging, consumers, retries, Saga state machines, and Outbox integration.
Q19. When Should You Use Saga?
- Business operations span multiple microservices.
- Each service owns its own database.
- Transactions are long-running.
- Business compensation is possible.
- There is no suitable global transaction across the participating services.
Q20. When Should You Use Outbox?
- A service updates a database and publishes an event.
- Database updates must not lose their corresponding events.
- Message broker availability may be intermittent.
- Reliable asynchronous integration is important.
- Consumers must receive events even when publication needs to be retried.
Q21. When Should You Avoid These Patterns?
- Simple CRUD applications with no distributed workflow.
- Applications where a normal database transaction is sufficient.
- Workflows where compensation cannot be defined and business owners have not agreed on failure handling.
- Small applications where the operational overhead is greater than the benefit.
| NET-Core-10-New-Features :👈 | 👉:ASP.NET Interview Questions-6 |