internal TaskOrchestrationDispatcher( IOrchestrationService orchestrationService, INameVersionObjectManager <TaskOrchestration> objectManager, DispatchMiddlewarePipeline dispatchPipeline) { this.objectManager = objectManager ?? throw new ArgumentNullException(nameof(objectManager)); this.orchestrationService = orchestrationService ?? throw new ArgumentNullException(nameof(orchestrationService)); this.dispatchPipeline = dispatchPipeline ?? throw new ArgumentNullException(nameof(dispatchPipeline)); this.dispatcher = new WorkItemDispatcher <TaskOrchestrationWorkItem>( "TaskOrchestrationDispatcher", item => item == null ? string.Empty : item.InstanceId, OnFetchWorkItemAsync, OnProcessWorkItemSessionAsync) { GetDelayInSecondsAfterOnFetchException = orchestrationService.GetDelayInSecondsAfterOnFetchException, GetDelayInSecondsAfterOnProcessException = orchestrationService.GetDelayInSecondsAfterOnProcessException, SafeReleaseWorkItem = orchestrationService.ReleaseTaskOrchestrationWorkItemAsync, AbortWorkItem = orchestrationService.AbandonTaskOrchestrationWorkItemAsync, DispatcherCount = orchestrationService.TaskOrchestrationDispatcherCount, MaxConcurrentWorkItems = orchestrationService.MaxConcurrentTaskOrchestrationWorkItems }; // To avoid starvation, we only allow half of all concurrently execution orchestrations to // leverage extended sessions. var maxConcurrentSessions = (int)Math.Ceiling(this.dispatcher.MaxConcurrentWorkItems / 2.0); this.concurrentSessionLock = new NonBlockingCountdownLock(maxConcurrentSessions); }
internal TaskOrchestrationDispatcher(MessagingFactory messagingFactory, TrackingDispatcher trackingDispatcher, TaskHubDescription taskHubDescription, TaskHubWorkerSettings workerSettings, string orchestratorEntityName, string workerEntityName, string trackingEntityName, INameVersionObjectManager <TaskOrchestration> objectManager) : base("TaskOrchestration Dispatcher", item => item.Session == null ? string.Empty : item.Session.SessionId) { this.taskHubDescription = taskHubDescription; settings = workerSettings.Clone(); this.orchestratorEntityName = orchestratorEntityName; this.workerEntityName = workerEntityName; this.trackingEntityName = trackingEntityName; this.messagingFactory = messagingFactory; this.messagingFactory.PrefetchCount = PrefetchCount; this.objectManager = objectManager; orchestratorQueueClient = this.messagingFactory.CreateQueueClient(this.orchestratorEntityName); workerSender = this.messagingFactory.CreateMessageSender(this.workerEntityName, this.orchestratorEntityName); trackingDipatcher = trackingDispatcher; if (trackingDipatcher != null) { isTrackingEnabled = true; trackingSender = this.messagingFactory.CreateMessageSender(this.trackingEntityName, this.orchestratorEntityName); } maxConcurrentWorkItems = settings.TaskOrchestrationDispatcherSettings.MaxConcurrentOrchestrations; }
internal TaskActivityDispatcher( IOrchestrationService orchestrationService, INameVersionObjectManager <TaskActivity> objectManager, DispatchMiddlewarePipeline dispatchPipeline, LogHelper logHelper) { this.orchestrationService = orchestrationService ?? throw new ArgumentNullException(nameof(orchestrationService)); this.objectManager = objectManager ?? throw new ArgumentNullException(nameof(objectManager)); this.dispatchPipeline = dispatchPipeline ?? throw new ArgumentNullException(nameof(dispatchPipeline)); this.logHelper = logHelper; this.dispatcher = new WorkItemDispatcher <TaskActivityWorkItem>( "TaskActivityDispatcher", item => item.Id, this.OnFetchWorkItemAsync, this.OnProcessWorkItemAsync) { AbortWorkItem = orchestrationService.AbandonTaskActivityWorkItemAsync, GetDelayInSecondsAfterOnFetchException = orchestrationService.GetDelayInSecondsAfterOnFetchException, GetDelayInSecondsAfterOnProcessException = orchestrationService.GetDelayInSecondsAfterOnProcessException, DispatcherCount = orchestrationService.TaskActivityDispatcherCount, MaxConcurrentWorkItems = orchestrationService.MaxConcurrentTaskActivityWorkItems, LogHelper = logHelper, }; }
/// <summary> /// Create a new TaskHubWorker with given OrchestrationService and name version managers /// </summary> /// <param name="orchestrationService">Reference the orchestration service implementation</param> /// <param name="orchestrationObjectManager">NameVersionObjectManager for Orchestrations</param> /// <param name="activityObjectManager">NameVersionObjectManager for Activities</param> public TaskHubWorker( IOrchestrationService orchestrationService, INameVersionObjectManager <TaskOrchestration> orchestrationObjectManager, INameVersionObjectManager <TaskActivity> activityObjectManager) { this.orchestrationManager = orchestrationObjectManager ?? throw new ArgumentException("orchestrationObjectManager"); this.activityManager = activityObjectManager ?? throw new ArgumentException("activityObjectManager"); this.orchestrationService = orchestrationService ?? throw new ArgumentException("orchestrationService"); }
/// <summary> /// Create a new TaskHubWorker with given OrchestrationService and name version managers /// </summary> /// <param name="orchestrationService">Reference the orchestration service implementation</param> /// <param name="orchestrationObjectManager">NameVersionObjectManager for Orchestrations</param> /// <param name="activityObjectManager">NameVersionObjectManager for Activities</param> public TaskHubWorker( IOrchestrationService orchestrationService, INameVersionObjectManager <TaskOrchestration> orchestrationObjectManager, INameVersionObjectManager <TaskActivity> activityObjectManager) : this( orchestrationService, orchestrationObjectManager, activityObjectManager, loggerFactory : null) { }
/// <summary> /// Create a new <see cref="TaskHubWorker"/> with given <see cref="IOrchestrationService"/> and name version managers /// </summary> /// <param name="orchestrationService">The orchestration service implementation</param> /// <param name="orchestrationObjectManager">The <see cref="INameVersionObjectManager{TaskOrchestration}"/> for orchestrations</param> /// <param name="activityObjectManager">The <see cref="INameVersionObjectManager{TaskActivity}"/> for activities</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to use for logging</param> public TaskHubWorker( IOrchestrationService orchestrationService, INameVersionObjectManager <TaskOrchestration> orchestrationObjectManager, INameVersionObjectManager <TaskActivity> activityObjectManager, ILoggerFactory loggerFactory = null) { this.orchestrationManager = orchestrationObjectManager ?? throw new ArgumentException("orchestrationObjectManager"); this.activityManager = activityObjectManager ?? throw new ArgumentException("activityObjectManager"); this.orchestrationService = orchestrationService ?? throw new ArgumentException("orchestrationService"); this.logHelper = new LogHelper(loggerFactory?.CreateLogger("DurableTask.Core")); }
internal TaskActivityDispatcher(MessagingFactory messagingFactory, TaskHubDescription taskHubDescription, TaskHubWorkerSettings workerSettings, string orchestratorQueueName, string workerQueueName, INameVersionObjectManager <TaskActivity> objectManager) : base("TaskActivityDispatcher", item => item.MessageId) { this.taskHubDescription = taskHubDescription; settings = workerSettings.Clone(); this.orchestratorQueueName = orchestratorQueueName; this.workerQueueName = workerQueueName; this.messagingFactory = messagingFactory; this.objectManager = objectManager; maxConcurrentWorkItems = settings.TaskActivityDispatcherSettings.MaxConcurrentActivities; }
/// <summary> /// Create a new TaskHubWorker with given name, Service Bus and Azure Storage connection string, /// and providing custom implementations for managing orchestrations and activities. /// </summary> /// <param name="hubName">Name of the Task Hub</param> /// <param name="connectionString">Service Bus connection string</param> /// <param name="tableStoreConnectionString">Azure Storage connection string</param> /// <param name="orchestrationManager">Custom implementation of <see cref="INameVersionObjectManager{TaskOrchestration}"/>.</param> /// <param name="activityManager">Custom implementation of <see cref="INameVersionObjectManager{TaskActivity}"/>.</param> /// <param name="workerSettings">Settings for various task hub worker options</param> public TaskHubWorker(string hubName, string connectionString, string tableStoreConnectionString, INameVersionObjectManager <TaskOrchestration> orchestrationManager, INameVersionObjectManager <TaskActivity> activityManager, TaskHubWorkerSettings workerSettings) { if (string.IsNullOrEmpty(hubName)) { throw new ArgumentException("hubName"); } if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentException("connectionString"); } if (workerSettings == null) { throw new ArgumentException("workerSettings"); } if (orchestrationManager == null) { throw new ArgumentException("orchestrationManager"); } if (activityManager == null) { throw new ArgumentException("activityManager"); } this.hubName = hubName.ToLower(); this.connectionString = connectionString; workerEntityName = string.Format(FrameworkConstants.WorkerEndpointFormat, this.hubName); orchestratorEntityName = string.Format(FrameworkConstants.OrchestratorEndpointFormat, this.hubName); trackingEntityName = string.Format(FrameworkConstants.TrackingEndpointFormat, this.hubName); this.orchestrationManager = orchestrationManager; this.activityManager = activityManager; this.tableStoreConnectionString = tableStoreConnectionString; this.workerSettings = workerSettings; }
internal TaskOrchestrationDispatcher( IOrchestrationService orchestrationService, INameVersionObjectManager <TaskOrchestration> objectManager, DispatchMiddlewarePipeline dispatchPipeline) { this.objectManager = objectManager ?? throw new ArgumentNullException(nameof(objectManager)); this.orchestrationService = orchestrationService ?? throw new ArgumentNullException(nameof(orchestrationService)); this.dispatchPipeline = dispatchPipeline ?? throw new ArgumentNullException(nameof(dispatchPipeline)); this.dispatcher = new WorkItemDispatcher <TaskOrchestrationWorkItem>( "TaskOrchestrationDispatcher", item => item == null ? string.Empty : item.InstanceId, this.OnFetchWorkItemAsync, this.OnProcessWorkItemAsync) { GetDelayInSecondsAfterOnFetchException = orchestrationService.GetDelayInSecondsAfterOnFetchException, GetDelayInSecondsAfterOnProcessException = orchestrationService.GetDelayInSecondsAfterOnProcessException, SafeReleaseWorkItem = orchestrationService.ReleaseTaskOrchestrationWorkItemAsync, AbortWorkItem = orchestrationService.AbandonTaskOrchestrationWorkItemAsync, DispatcherCount = orchestrationService.TaskOrchestrationDispatcherCount, MaxConcurrentWorkItems = orchestrationService.MaxConcurrentTaskOrchestrationWorkItems }; }
public FakeOrchestrationExecutor(INameVersionObjectManager <TaskOrchestration> orchestrationObjectManager) { scheduler = new SynchronousTaskScheduler(); dataConverter = new JsonDataConverter(); this.orchestrationObjectManager = orchestrationObjectManager; }