private DataFeed ProcessFeedItem(string groupSelector, bool infiniteLoop = false) { var config = this.configProvider.GetConfigurationSection <FeedProcessingConfig>(); using (ICommandReceiver receiver = Factory.GetInstance <ICommandReceiver>().Open(config.InputQueueId, groupSelector)) { DataFeed command; do { command = receiver.GetCommand <DataFeed>(); if (command == null) { return(null); } if (command.IsSequenceTerminator) { this.ProcessTerminator(command); } else { this.ProcessFeed(command); } }while (infiniteLoop); return(command); } }
public void Run() { using (ICommandReceiver receiver = Factory.GetInstance <ICommandReceiver>().Open(CONST_MembersDeltaQueueName)) { while (true) { UpdateMembersDeltaCommand command = null; try { command = receiver.GetCommand <UpdateMembersDeltaCommand>(); if (command == null) { this.log.Debug("No export command found. Processing stopped."); return; } using (this.unitOfWorkProvider.CreateUnitOfWork()) { var state = this.vkGroupRepository.GetProcessingState(command.VkGroupId, DataFeedType.MembersInfo); if (state == null) { this.log.WarnFormat("MembersInfo processing state is not found for VkGroupId = \"{0}\"", command.VkGroupId); return; } if (command.Version < state.Version) { this.log.WarnFormat("Processing state of command is outdate. Command.Version = {0} and State.Version = {1}", command.Version, state.Version); return; } this.log.DebugFormat("Processing member delta for vkgroup = \"{0}\" on \"{1}\" for version = {2}", command.VkGroupId, command.SendingDate, command.Version); this.deltaUpdater.CalculateMembersDelta(command.VkGroupId, DateTime.UtcNow); } } catch (Exception exc) { this.log.ErrorFormat("Exception is occured while updating members delta for the group with Id = {0}: {1}", command != null ? command.VkGroupId : 0, exc.ToString()); } finally { if (command != null) { command.MarkAsCompleted(); } } } } }
private ExportResultCommand GetExportResult(string ticketId) { using (ICommandReceiver receiver = Factory.GetInstance <ICommandReceiver>().Open(CONST_ExportResultQueueName, string.Format("TicketId = '{0}'", ticketId))) { ExportResultCommand result = receiver.GetCommand <ExportResultCommand>(); if (result != null) { result.MarkAsCompleted(); } return(result); } }
private CreateProjectResultCommand DoGetCreateProjectStatus(string ticketId) { using (ICommandReceiver receiver = Factory.GetInstance <ICommandReceiver>().Open(CONST_CreateProjectResultQueueName, string.Format("TicketId = '{0}'", ticketId))) { CreateProjectResultCommand result = receiver.GetCommand <CreateProjectResultCommand>(); if (result != null) { result.MarkAsCompleted(); } return(result); } }
public void Execute() { using (ICommandReceiver commandReceiver = Factory.GetInstance <ICommandReceiver>().Open("FeedJobQueue")) { while (true) { var feedQueueItem = commandReceiver.GetCommand <FeedQueueItem>(); if (feedQueueItem == null) { break; } feedQueueItem.MarkAsCompleted(); } } }
public void ProcessExportQueue() { using (ICommandReceiver receiver = Factory.GetInstance <ICommandReceiver>().Open(CONST_ExportQueueName)) { while (true) { ExportReportCommand exportCommand = null; try { exportCommand = receiver.GetCommand <ExportReportCommand>(); if (exportCommand == null) { this.log.Debug("No export command found. Processing stopped."); return; } string fileName = this.GenerateFileName(exportCommand); IFileSystem fileSystem = this.fileSystemFactory.CreateFileSystem(exportCommand.InitiatorUserId); byte[] exportResult = this.dataProvider.ExportToXlsx(exportCommand.VkGroupId, exportCommand.DateRange); string virtualFilePath = fileSystem.SaveToFile(fileName, exportResult); this.SendExportFinished(exportCommand, true, virtualFilePath); } catch (Exception exc) { this.log.ErrorFormat("Exception is occured while processing a group Id = {0}, for userId = {1}: {2}", exportCommand != null ? exportCommand.VkGroupId : 0, exportCommand != null ? exportCommand.InitiatorUserId : 0, exc.ToString()); if (exportCommand != null) { this.SendExportFinished(exportCommand, isSuccess: false); } } finally { if (exportCommand != null) { exportCommand.MarkAsCompleted(); } } } } }
public void ProcessNextQueueItem() { this.log.Info("GetFeedsFromVKAction process started"); var processingConfig = this.configProvider.GetConfigurationSection <FeedProcessingConfig>(); var selector = !string.IsNullOrWhiteSpace(processingConfig.FeedFilter) ? processingConfig.FeedFilter : null; using (ICommandReceiver commandReceiver = Factory.GetInstance <ICommandReceiver>().Open(processingConfig.InputQueueId, selector)) { IVkDataProvider vkDataProvider = this.vkConnectionBuilder.GetVkDataProvider(); for (int i = 0; i < CONST_BatchProcessingSize; i++) { FeedQueueItem queueItem = null; try { queueItem = commandReceiver.GetCommand <FeedQueueItem>(); if (queueItem == null) { this.log.Info("No items in queue found. Processing stopped."); return; } this.ProcessQueueItem(queueItem, vkDataProvider, processingConfig); } finally { if (queueItem != null) { queueItem.MarkAsCompleted(); using (ICommandSender commandSender = Factory.GetInstance <ICommandSender>().Open(processingConfig.InputQueueId)) { commandSender.SendCommand(queueItem.Copy()); } } } } } }
public void Run() { using (ICommandReceiver receiver = Factory.GetInstance <ICommandReceiver>().Open(CONST_CreateProjectQueueName)) { while (true) { CreateProjectCommand createProjectCommand = null; try { createProjectCommand = receiver.GetCommand <CreateProjectCommand>(); if (createProjectCommand == null) { this.log.Debug("No create project command found."); return; } var project = this.CreateProject(createProjectCommand); this.SendCreateProjectFinished(createProjectCommand, project, true); } catch (Exception exc) { this.log.ErrorFormat("Exception is occured while creating a project VkUrl {0}, Title {1} for userId = {2}: {3}", createProjectCommand != null ? createProjectCommand.Url : string.Empty, createProjectCommand != null ? createProjectCommand.Title : string.Empty, createProjectCommand != null ? createProjectCommand.AccountId : 0, exc.ToString()); if (createProjectCommand != null) { this.SendCreateProjectFinished(createProjectCommand, new Project(), isSuccess: false); } } finally { if (createProjectCommand != null) { createProjectCommand.MarkAsCompleted(); } } } } }
private void ProcessSpecificGroupFeeds(FeedProcessingConfig processingConfig) { using (ICommandReceiver groupReceiver = Factory.GetInstance <ICommandReceiver>().Open(processingConfig.GroupQueueId)) { while (true) { GroupQueueItem commandMessage = null; try { commandMessage = groupReceiver.GetCommand <GroupQueueItem>(); if (commandMessage == null) { this.log.Error("No groups found to process. Processing stopped."); return; } this.ProcessGroup(commandMessage.VkGroupId); } catch (Exception exc) { this.log.ErrorFormat("Exception is occured while processing a group Id = {0}: {1}", commandMessage != null ? commandMessage.VkGroupId : 0, exc.ToString()); return; } finally { if (commandMessage != null) { commandMessage.MarkAsCompleted(); using (ICommandSender groupSender = Factory.GetInstance <ICommandSender>().Open(processingConfig.GroupQueueId)) { groupSender.SendCommand(new GroupQueueItem(commandMessage.VkGroupId)); } } } } } }