Extensions and helpers to interact with DTFx
$ dotnet add package DurableTask.SymphonyThis repo contains the library code to interact with Durable Task Framework (DTFx) using MS SQL as the Orchestration Hub backend.
It contains wrappers, services, extensions, and other helper methods to configure and use TaskHubClient and TaskHubWorker as injectable services, as well as reading state information from the configured OrchestrationServiceBase, which configured to use SQL server as a task hub.
Run Create-DurableTables.sql in the config/ directory of this repo. This will create the required tables and stored procedures for the Orchestration Hub.
In the IHost ConfigureServices() configuration methods, use the extension methods to configure the Orchestration Hub and the Task Worker.
IHost.CreateDefaultBuilder(args)
.ConfigureServices((hostBuilderContext, services) =>
{
services.AddOrchestrationHub(options =>
{
// Adds the backing SQL connection for storage and persistence
options.ConnectionString = "DurableContextSQLConnectionString"
options.MaxActiveOrchestrations = 10;
})
.AddTaskWorker(options =>
{
// Adds the Task Worker hosted services
options.ErrorPropagationMode = ErrorPropagationMode.UseFailureDetails);
});
// Register all Orchestrations and Activities automatically:
services.AutoRegisterOrchestrationsAndActivities()
// Register Orchestrations and Activities manually by listing Types:
services.WithRegisteredOrchestrations(new[]
{
// Adds Orchestrations as transient services and registers them with the Task Worker
typeof(SampleOrchestration),
typeof(AnotherOrchestration)
})
.WithRegisteredActivities(new[]
{
// Adds Activities and transient services and registers them with the Task Worker
typeof(SampleActivity),
typeof(AnotherActivity)
});
})
.Build();
Orchestrations must be classes that implement TaskOrchestration<TOutput, TInput>. Activities must be classes that implement TaskActivity<TInput, TOutput> or AsyncTaskActivity<TInput, TOutput>.
Orchestrations and Activities must be registered on the task worker (server) to function.
In the IHost ConfigureServices() configuration methods, use the extension methods to configure the connection to the Orchestration Hub.
IHost.CreateDefaultBuilder(args)
.ConfigureServices((hostBuilderContext, services) =>
{
services.AddOrchestrationHub(options =>
{
// Adds the backing SQL connection for storage and persistence
options.ConnectionString = "DurableContextSQLConnectionString"
})
.AddTaskClient();
})
.Build();
To start an Orchestration, inject an instance of the ITaskClient service and use the StartOrchestration or ScheduleOrchestration methods.