Introduction: What is Durable Service? How we create a Durable Service?
- Durable services are WCF services that persist service state information even after service host is restarted or Client.
- Durable services have the capability to restore their own state when they are recycled.
- It can use data store like SQL database for maintain instance state.
- It is new feature in .Net 3.5.
Defining the Durable Service:
- Durable service can be implemented using [DurableService()] attribute.
- It takes 'CanCreateInstance' and 'CompletesInstance'
property to mention on which operation instance state has to be saved and
destroyed.
- CanCreateInstance = true: Calling this operation results in creating the serialization and inserting it into the datastore.
- CompletesInstance = true: Calling this operation results in deleting the persisted instance from the datastore.
Code:
[Serializable]
[DurableService()]
public class
MyService :IMyservice
{
[DurableOperation(CanCreateInstance = true)]
public int StartPersistance()
{
//Do Something
}
[DurableOperation(CompletesInstance =
true)]
public void EndPersistence()
{
//Do Something
}
}
Comments
Join the conversation! Your thoughts help the community grow.