private static void TestStep2(IMessageBus messageBus, JobCompleteEvent obj) { _testLog.LogInformation("Sending create command to ServerB"); // Subscribe to the Job complete event, so we can move to the next step as soon as it is ready messageBus.Subscribe <JobCompleteEvent>(b => b .WithTopic(JobCompleteEvent.ChannelSuccess) .Invoke(m => TestStep3(messageBus, m)) .OnThreadPool() .MaximumEvents(1)); // Command ServerB to create a new stitch instance var response = messageBus.RequestWait <CreateInstanceRequest, CreateInstanceResponse>(new CreateInstanceRequest { GroupName = _groupName, LocalOnly = false, Name = "Stitch", NumberOfInstances = 2 }); if (!response.IsSuccess) { _testLog.LogError("Could not create stitch instance"); } }
private void OnJobComplete(string jobId, CommandJob job) { _log.LogDebug("Job Id={0} is complete: {1}", jobId, job.Status); var completeEvent = new JobCompleteEvent { JobId = job.Id, Status = job.Status }; string channel = completeEvent.Status == JobStatusType.Success ? JobCompleteEvent.ChannelSuccess : JobCompleteEvent.ChannelFailure; _messageBus.Publish(channel, completeEvent); }
private static void TestStep3(IMessageBus messageBus, JobCompleteEvent obj) { _testLog.LogInformation("Sending start command to ServerB"); Thread.Sleep(5000); messageBus.Subscribe <JobCompleteEvent>(b => b .WithTopic(JobCompleteEvent.ChannelSuccess) .Invoke(m => TestStep4(messageBus, m)) .OnThreadPool() .MaximumEvents(1)); // Command ServerB to start the stitch instance var response = messageBus.RequestWait <CommandRequest, CommandResponse>(new CommandRequest { Command = CommandType.StartStitchGroup, Target = _groupName.ToString() }); if (response.Result != CommandResultType.Started) { _testLog.LogError("Could not start stitch instance"); } }
private static void TestStep4(IMessageBus messageBus, JobCompleteEvent obj) { // Do something to prove that it works as expected _testLog.LogInformation("SUCCESS"); }