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(); } } } } }
public void ProcessTerminator(int vkGroupId, int feedTypeVersion) { using (ICommandSender commandSender = Factory.GetInstance <ICommandSender>().Open(CONST_UpdateMembersDeltaProcessQueue)) { var command = new UpdateMembersDeltaCommand { VkGroupId = vkGroupId, Version = feedTypeVersion }; commandSender.SendCommand(command); } }