Table of Contents

Class TaskHubWorker

Namespace
DurableTask.Core
Assembly
DurableTask.Core.dll

Allows users to load the TaskOrchestration and TaskActivity classes and start dispatching to these. Also allows CRUD operations on the Task Hub itself.

public sealed class TaskHubWorker : IDisposable
Inheritance
TaskHubWorker
Implements
Inherited Members

Constructors

TaskHubWorker(IOrchestrationService)

Create a new TaskHubWorker with given OrchestrationService

public TaskHubWorker(IOrchestrationService orchestrationService)

Parameters

orchestrationService IOrchestrationService

Reference the orchestration service implementation

TaskHubWorker(IOrchestrationService, INameVersionObjectManager<TaskOrchestration>, INameVersionObjectManager<TaskActivity>)

Create a new TaskHubWorker with given OrchestrationService and name version managers

public TaskHubWorker(IOrchestrationService orchestrationService, INameVersionObjectManager<TaskOrchestration> orchestrationObjectManager, INameVersionObjectManager<TaskActivity> activityObjectManager)

Parameters

orchestrationService IOrchestrationService

Reference the orchestration service implementation

orchestrationObjectManager INameVersionObjectManager<TaskOrchestration>

NameVersionObjectManager for Orchestrations

activityObjectManager INameVersionObjectManager<TaskActivity>

NameVersionObjectManager for Activities

Properties

TaskActivityDispatcher

Gets the task activity dispatcher

public TaskActivityDispatcher TaskActivityDispatcher { get; }

Property Value

TaskActivityDispatcher

TaskOrchestrationDispatcher

Gets the orchestration dispatcher

public TaskOrchestrationDispatcher TaskOrchestrationDispatcher { get; }

Property Value

TaskOrchestrationDispatcher

orchestrationService

Reference to the orchestration service used by the task hub worker

public IOrchestrationService orchestrationService { get; }

Property Value

IOrchestrationService

Methods

AddActivityDispatcherMiddleware(Func<DispatchMiddlewareContext, Func<Task>, Task>)

Adds a middleware delegate to the activity dispatch pipeline.

public void AddActivityDispatcherMiddleware(Func<DispatchMiddlewareContext, Func<Task>, Task> middleware)

Parameters

middleware Func<DispatchMiddlewareContext, Func<Task>, Task>

Delegate to invoke whenever a message is dispatched to an activity.

AddOrchestrationDispatcherMiddleware(Func<DispatchMiddlewareContext, Func<Task>, Task>)

Adds a middleware delegate to the orchestration dispatch pipeline.

public void AddOrchestrationDispatcherMiddleware(Func<DispatchMiddlewareContext, Func<Task>, Task> middleware)

Parameters

middleware Func<DispatchMiddlewareContext, Func<Task>, Task>

Delegate to invoke whenever a message is dispatched to an orchestration.

AddTaskActivities(params ObjectCreator<TaskActivity>[])

Loads user defined TaskActivity classes in the TaskHubWorker

public TaskHubWorker AddTaskActivities(params ObjectCreator<TaskActivity>[] taskActivityCreators)

Parameters

taskActivityCreators ObjectCreator<TaskActivity>[]

User specified ObjectCreators that will create classes deriving TaskActivity with specific names and versions

Returns

TaskHubWorker

AddTaskActivities(params TaskActivity[])

Loads user defined TaskActivity objects in the TaskHubWorker

public TaskHubWorker AddTaskActivities(params TaskActivity[] taskActivityObjects)

Parameters

taskActivityObjects TaskActivity[]

Objects of with TaskActivity base type

Returns

TaskHubWorker

AddTaskActivities(params Type[])

Loads user defined TaskActivity classes in the TaskHubWorker

public TaskHubWorker AddTaskActivities(params Type[] taskActivityTypes)

Parameters

taskActivityTypes Type[]

Types deriving from TaskOrchestration class

Returns

TaskHubWorker

AddTaskActivitiesFromInterface<T>(T)

Infers and adds every method in the specified interface T on the passed in object as a different TaskActivity with Name set to the method name and version set to an empty string. Methods can then be invoked from task orchestrations by calling ScheduleTask(name, version) with name as the method name and string.Empty as the version.

public TaskHubWorker AddTaskActivitiesFromInterface<T>(T activities)

Parameters

activities T

Object that implements this interface

Returns

TaskHubWorker

Type Parameters

T

Interface

AddTaskActivitiesFromInterface<T>(T, bool)

Infers and adds every method in the specified interface T on the passed in object as a different TaskActivity with Name set to the method name and version set to an empty string. Methods can then be invoked from task orchestrations by calling ScheduleTask(name, version) with name as the method name and string.Empty as the version.

public TaskHubWorker AddTaskActivitiesFromInterface<T>(T activities, bool useFullyQualifiedMethodNames)

Parameters

activities T

Object that implements this interface

useFullyQualifiedMethodNames bool

If true, the method name translation from the interface contains the interface name, if false then only the method name is used

Returns

TaskHubWorker

Type Parameters

T

Interface

AddTaskOrchestrations(params ObjectCreator<TaskOrchestration>[])

Loads user defined TaskOrchestration classes in the TaskHubWorker

public TaskHubWorker AddTaskOrchestrations(params ObjectCreator<TaskOrchestration>[] taskOrchestrationCreators)

Parameters

taskOrchestrationCreators ObjectCreator<TaskOrchestration>[]

User specified ObjectCreators that will create classes deriving TaskOrchestrations with specific names and versions

Returns

TaskHubWorker

AddTaskOrchestrations(params Type[])

Loads user defined TaskOrchestration classes in the TaskHubWorker

public TaskHubWorker AddTaskOrchestrations(params Type[] taskOrchestrationTypes)

Parameters

taskOrchestrationTypes Type[]

Types deriving from TaskOrchestration class

Returns

TaskHubWorker

Dispose()

public void Dispose()

StartAsync()

Starts the TaskHubWorker so it begins processing orchestrations and activities

public Task<TaskHubWorker> StartAsync()

Returns

Task<TaskHubWorker>

StopAsync()

Gracefully stops the TaskHubWorker

public Task StopAsync()

Returns

Task

StopAsync(bool)

Stops the TaskHubWorker

public Task StopAsync(bool isForced)

Parameters

isForced bool

True if forced shutdown, false if graceful shutdown

Returns

Task