public void EnqueueDirectlyTo(string queue, string subqueue, MessagePayload payload) { EnsureEnlistment(); var message = new PersistentMessage { Data = payload.Data, Headers = payload.Headers, Id = new MessageId { SourceInstanceId = _queueStorage.Id, MessageIdentifier = GuidCombGenerator.Generate() }, Queue = queue, SentAt = DateTime.Now, SubQueue = subqueue, Status = MessageStatus.EnqueueWait }; _queueStorage.Global(actions => { var queueActions = actions.GetQueue(queue); var bookmark = queueActions.Enqueue(message); actions.RegisterUpdateToReverse(Enlistment.Id, bookmark, MessageStatus.EnqueueWait, subqueue); actions.Commit(); }); OnMessageQueuedForReceive(message); lock (_newMessageArrivedLock) Monitor.PulseAll(_newMessageArrivedLock); }
public MessageBookmark MoveTo(string subQueue, PersistentMessage message) { var path = message.Bookmark.Bookmark; var id = FileUtil.ToMessageId(path); if (!File.Exists(path)) return null; var msgPath = Path.Combine(_msgsPath, subQueue); var newPath = FileUtil.MoveBase(path, _msgsPath, msgPath, MessageStatus.SubqueueChanged.ToString()); var bookmark = new MessageBookmark { Bookmark = newPath, QueueName = _queueName }; _logger.DebugFormat("Moving message {0} to subqueue {1}", id, _queueName); return bookmark; }