protected async Task JumpStartOrchestrationAsync(OrchestrationJumpStartInstanceEntity jumpStartEntity) { var instance = jumpStartEntity.State.OrchestrationInstance; OrchestrationStateInstanceEntity stateEntity = (await this.service.InstanceStore.GetEntitiesAsync(instance.InstanceId, instance.ExecutionId))?.FirstOrDefault(); if (stateEntity != null) { // It seems orchestration started, delete entity from JumpStart table await this.service.InstanceStore.DeleteJumpStartEntitiesAsync(new[] { jumpStartEntity }); } else if (!jumpStartEntity.JumpStartTime.IsSet() && jumpStartEntity.State.CreatedTime + this.ignoreWindow < DateTime.UtcNow) { // JumpStart orchestration var startedEvent = new ExecutionStartedEvent(-1, jumpStartEntity.State.Input) { Tags = jumpStartEntity.State.Tags, Name = jumpStartEntity.State.Name, Version = jumpStartEntity.State.Version, OrchestrationInstance = jumpStartEntity.State.OrchestrationInstance }; var taskMessage = new TaskMessage { OrchestrationInstance = jumpStartEntity.State.OrchestrationInstance, Event = startedEvent }; await this.service.SendTaskOrchestrationMessageAsync(taskMessage); TraceHelper.Trace( TraceEventType.Information, "JumpStartManager-SendTaskOrchestrationMessage", $"JumpStartManager: SendTaskOrchestrationMessageAsync({instance.InstanceId}, {instance.ExecutionId}) success!"); // Now update the JumpStart table jumpStartEntity.JumpStartTime = DateTime.UtcNow; await this.service.InstanceStore.WriteJumpStartEntitiesAsync(new[] { jumpStartEntity }); TraceHelper.Trace( TraceEventType.Information, "JumpStartManager-WriteJumpStartEntities", $"JumpStartManager: WriteJumpStartEntitiesAsync({instance.InstanceId}, {instance.ExecutionId}) success!"); } }
public async Task VerifyWriteEntitiesFailsForUnexpectedType() { var state = new OrchestrationJumpStartInstanceEntity(); await Assert.ThrowsExceptionAsync <InvalidOperationException>(() => InstanceStore.WriteEntitiesAsync(new[] { state })); }
/// <summary> /// Creates a new AzureTableOrchestrationJumpStartEntity with the jumpstart state and datetime /// </summary> /// <param name="jumpStartEvent"></param> public AzureTableOrchestrationJumpStartEntity(OrchestrationJumpStartInstanceEntity jumpStartEvent) : base(jumpStartEvent.State) { this.JumpStartTime = jumpStartEvent.JumpStartTime; }