public async Task SendPeriodEndTask(short collectionYear, byte collectionPeriod, long jobId, string taskName) { try { dataContext.ClearJobFromDcJobId(jobId); var dto = new JobContextDto { JobId = jobId, KeyValuePairs = new Dictionary <string, object> { { JobContextMessageKey.UkPrn, 0 }, { JobContextMessageKey.Filename, string.Empty }, { JobContextMessageKey.CollectionYear, collectionYear }, { JobContextMessageKey.ReturnPeriod, collectionPeriod }, { JobContextMessageKey.Username, "PV2-Automated" } }, SubmissionDateTimeUtc = DateTime.UtcNow, TopicPointer = 0, Topics = new List <TopicItemDto> { new TopicItemDto { SubscriptionName = "Payments", Tasks = new List <TaskItemDto> { new TaskItemDto { SupportsParallelExecution = false, Tasks = new List <string> { taskName } } } } } }; var topicPublishingService = topicPublishingServiceFactory.GetPeriodEndTaskPublisher(); await topicPublishingService.PublishAsync(dto, new Dictionary <string, object> { { "To", "Payments" } }, $"Payments_{taskName}"); } catch (Exception e) { Console.WriteLine(e); throw; } }