Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 1.09 KB

handlers-and-sagas.md

File metadata and controls

22 lines (17 loc) · 1.09 KB
title summary component reviewed related
Handlers and Sagas
A brief introduction to handlers and sagas
Core
2025-02-19
nservicebus/handlers
nservicebus/sagas
samples/saga

There are two standard ways of executing code when a message is processed: handlers and sagas.

Handler instances are instantiated on a per-message basis, executed, and then disposed of. These are sometimes referred to as “stateless handlers”.

Saga instances are also instantiated on a per-message basis, executed, and then disposed of. However they differ from handlers in that, once instantiated, they are passed an instance of a "Data" class. The "Saga Data" is persistent state that is shared between a given saga type based on a key. These are sometimes referred to as “stateful handlers”.

Other concepts that both handlers and sagas share: