コード例 #1
0
ファイル: QueueManager.cs プロジェクト: BclEx/rhino-esb
        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);
        }
コード例 #2
0
ファイル: QueueActions.cs プロジェクト: BclEx/rhino-esb
 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;
 }