Exemplo n.º 1
0
        public async Task SimplestGreetingsJumpStartTest()
        {
            var    sbService = (ServiceBusOrchestrationService)this.taskHub.orchestrationService;
            string name      = NameVersionHelper.GetDefaultName(typeof(SimplestGreetingsOrchestration));
            string version   = NameVersionHelper.GetDefaultVersion(typeof(SimplestGreetingsOrchestration));

            await this.taskHub.AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration))
            .AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask))
            .StartAsync();

            OrchestrationInstance id = await TestHelpers.CreateOrchestrationInstanceAsync(sbService, name, version, null, null, true, false);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 60));
            Assert.AreEqual("Greeting send to Gabbar", SimplestGreetingsOrchestration.Result,
                            "Orchestration Result is wrong!!!");
        }
Exemplo n.º 2
0
        public async Task DupeDetectionByInstanceStoreTest()
        {
            var    sbService = (ServiceBusOrchestrationService)this.taskHub.orchestrationService;
            string name      = NameVersionHelper.GetDefaultName(typeof(SimplestGreetingsOrchestration));
            string version   = NameVersionHelper.GetDefaultVersion(typeof(SimplestGreetingsOrchestration));

            await this.taskHub.AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration))
            .AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask))
            .StartAsync();

            // Write to jumpStart table only
            OrchestrationInstance id = await TestHelpers.CreateOrchestrationInstanceAsync(sbService, name, version, null, null, true, false);

            // Try to create orchestration with same instanceId
            OrchestrationAlreadyExistsException exception = await TestHelpers.ThrowsAsync <OrchestrationAlreadyExistsException>(() => TestHelpers.CreateOrchestrationInstanceAsync(sbService, name, version, id.InstanceId, null, false, false));

            Assert.IsTrue(exception.Message.Contains("already exists"));
        }
Exemplo n.º 3
0
        public OrchestrationTestHost AddTaskActivitiesFromInterface <T>(T activities, bool useFullyQualifiedMethodNames)
        {
            Type @interface = typeof(T);

            if ([email protected])
            {
                throw new Exception("Contract can only be an interface.");
            }

            foreach (MethodInfo methodInfo in @interface.GetMethods())
            {
                TaskActivity taskActivity            = new ReflectionBasedTaskActivity(activities, methodInfo);
                ObjectCreator <TaskActivity> creator =
                    new NameValueObjectCreator <TaskActivity>(
                        NameVersionHelper.GetDefaultName(methodInfo, useFullyQualifiedMethodNames),
                        NameVersionHelper.GetDefaultVersion(methodInfo), taskActivity);
                activityObjectManager.Add(creator);
            }
            return(this);
        }
Exemplo n.º 4
0
            protected override async Task ExecuteAsync(CancellationToken stoppingToken)
            {
                OrchestrationInstance instance = await _client.CreateOrchestrationInstanceAsync(
                    NameVersionHelper.GetDefaultName(typeof(GreetingsOrchestration)),
                    NameVersionHelper.GetDefaultVersion(typeof(GreetingsOrchestration)),
                    _instanceId,
                    null,
                    new Dictionary <string, string>()
                {
                    ["CorrelationId"] = Guid.NewGuid().ToString(),
                });

                OrchestrationState result = await _client.WaitForOrchestrationAsync(
                    instance, TimeSpan.FromSeconds(60));

                _console.WriteLine();
                _console.WriteLine($"Orchestration finished.");
                _console.WriteLine($"Run stats: {result.Status}");
                _console.WriteLine("Press Ctrl+C to exit");
            }
Exemplo n.º 5
0
        public async Task DupeDetectionByServiceBusQueueTest()
        {
            var    sbService = (ServiceBusOrchestrationService)this.taskHub.orchestrationService;
            string name      = NameVersionHelper.GetDefaultName(typeof(SimplestGreetingsOrchestration));
            string version   = NameVersionHelper.GetDefaultVersion(typeof(SimplestGreetingsOrchestration));

            await this.taskHub.AddTaskOrchestrations(typeof(GenerationBasicOrchestration))
            .AddTaskActivities(new GenerationBasicTask())
            .AddTaskOrchestrations(typeof(SimplestGreetingsOrchestration))
            .AddTaskActivities(typeof(SimplestGetUserTask), typeof(SimplestSendGreetingTask))
            .StartAsync();

            GenerationBasicTask.GenerationCount = 0;
            var generationCount      = 0;
            OrchestrationInstance id = await this.client.CreateOrchestrationInstanceAsync(typeof(GenerationBasicOrchestration), generationCount);

            bool isCompleted = await TestHelpers.WaitForInstanceAsync(this.client, id, 60);

            Assert.IsTrue(isCompleted, TestHelpers.GetInstanceNotCompletedMessage(this.client, id, 60));

            // We use instanceId and execution for SB level d-dup
            // Write to ServiceBus only. SB drops the message and the orchestration does not start
            id = await TestHelpers.CreateOrchestrationInstanceAsync(sbService, name, version, id.InstanceId, id.ExecutionId, false, true);

            await Task.Delay(TimeSpan.FromSeconds(5));

            // ReSharper disable once UnusedVariable
            long count = TestHelpers.GetOrchestratorQueueMessageCount();

            IList <OrchestrationState> executions = await this.client.GetOrchestrationStateAsync(id.InstanceId, true);

            Assert.AreEqual(1, executions.Count, "Duplicate detection failed and orchestration ran for second time");

            // Make sure the second orchestration never started by checking the output from first orchestration
            Assert.AreNotEqual("Greeting send to Gabbar", executions[0].Output);
            Assert.AreEqual(generationCount + 1, int.Parse(executions[0].Output));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NamedTypeDescriptor{TBase}"/> class.
 /// </summary>
 /// <param name="type">The service type.</param>
 public NamedTypeDescriptor(Type type)
     : this(type, NameVersionHelper.GetDefaultName(type), NameVersionHelper.GetDefaultVersion(type))
 {
 }
Exemplo n.º 7
0
 void Initialize(object obj)
 {
     Name    = NameVersionHelper.GetDefaultName(obj);
     Version = NameVersionHelper.GetDefaultVersion(obj);
 }
Exemplo n.º 8
0
 public Task <T> RunOrchestration <T>(OrchestrationInstance instance, Type orchestrationType, object input)
 {
     return(RunOrchestration <T>(instance, NameVersionHelper.GetDefaultName(orchestrationType),
                                 NameVersionHelper.GetDefaultVersion(orchestrationType), input));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskAliasAttribute"/> class.
 /// </summary>
 /// <param name="type">The type to get the default name and version from.</param>
 /// <param name="version">The version for this task.</param>
 public TaskAliasAttribute(Type type, string version = null)
 {
     Check.NotNull(type, nameof(type));
     Name    = NameVersionHelper.GetDefaultName(type);
     Version = string.IsNullOrEmpty(version) ? NameVersionHelper.GetDefaultVersion(type) : version;
 }
Exemplo n.º 10
0
 void Initialize()
 {
     Name    = NameVersionHelper.GetDefaultName(typeof(T));
     Version = NameVersionHelper.GetDefaultVersion(typeof(T));
 }
Exemplo n.º 11
0
 void Initialize(object obj)
 {
     this.Name    = $"@{NameVersionHelper.GetDefaultName(obj)}";
     this.Version = NameVersionHelper.GetDefaultVersion(obj);
 }