예제 #1
0
 public MessageId Send(Uri uri, MessagePayload payload)
 {
     if (_waitingForAllMessagesToBeSent)
         throw new CannotSendWhileWaitingForAllMessagesToBeSentException("Currently waiting for all messages to be sent, so we cannot send. You probably have a race condition in your application.");
     EnsureEnlistment();
     var parts = uri.AbsolutePath.Substring(1).Split('/');
     var queue = parts[0];
     string subqueue = null;
     if (parts.Length > 1)
         subqueue = string.Join("/", parts.Skip(1).ToArray());
     var msgId = Guid.Empty;
     var destination = uri.Host;
     _queueStorage.Global(actions =>
     {
         msgId = actions.RegisterToSend(destination, queue, subqueue, payload, Enlistment.Id);
         actions.Commit();
     });
     var messageId = new MessageId
     {
         SourceInstanceId = _queueStorage.Id,
         MessageIdentifier = msgId
     };
     var message = new Message
     {
         Id = messageId,
         Data = payload.Data,
         Headers = payload.Headers,
         Queue = queue,
         SubQueue = subqueue
     };
     OnMessageQueuedForSend(new MessageEventArgs(destination, message));
     return messageId;
 }
예제 #2
0
파일: Queue.cs 프로젝트: BclEx/rhino-esb
 public void EnqueueDirectlyTo(string subqueue, MessagePayload payload)
 {
     _queueManager.EnqueueDirectlyTo(_queueName, subqueue, payload);
 }
예제 #3
0
        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);
        }