Ejemplo n.º 1
0
        public void DeliverOrder(int idQueue)
        {
            var objQueue = _queueRepository.Get(idQueue, new string[] { "Order" });

            if (objQueue == null)
            {
                AddError("Queue not found");
                return;
            }
            var objQueueHistory = new QueueHistory(objQueue);

            _queueHistoryRepository.Create(objQueueHistory);
            _queueRepository.Delete(objQueue);
            Commit();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Process an inbound frame.
        /// </summary>
        /// <param name="client">Connection that received the frame</param>
        /// <param name="request">Inbound frame to process</param>
        /// <returns>
        /// Frame to send back
        /// </returns>
        /// <exception cref="BadRequestException">
        /// Missing the ID header in the frame.
        /// or
        /// </exception>
        public IFrame Process(IStompClient client, IFrame request)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            var id = request.Headers["id"];

            if (string.IsNullOrEmpty(id))
            {
                throw new BadRequestException(request, "Missing the ID header in the frame.");
            }

            var subscription = client.RemoveSubscription(id);

            if (subscription == null)
            {
                throw new BadRequestException(request, string.Format("Failed to find an subscription with id '{0}'.", id));
            }

            var queue = _queueRepository.Get(subscription.QueueName);

            if (queue == null)
            {
                //TODO: Log that the queue do not exist (even though our subscription existed).
                return(null);
            }

            queue.Unsubscribe(subscription);
            return(null);
        }
Ejemplo n.º 3
0
        private IStompQueue GetQueue(IFrame request)
        {
            var destinationName = request.Headers["destination"];

            if (string.IsNullOrEmpty(destinationName))
            {
                throw new BadRequestException(request, "'destination' header is empty.");
            }
            return(_queueRepository.Get(destinationName));
        }
Ejemplo n.º 4
0
        private IStompQueue GetQueue(IFrame request)
        {
            var queueName = request.Headers["destination"];

            if (queueName == null)
            {
                throw new BadRequestException(request, "You must specify the 'destination' header in the SUBSCRIBE frame.");
            }

            return(_queueRepository.Get(queueName));
        }
Ejemplo n.º 5
0
        private void NackMessages(Subscription subscription, string id)
        {
            var nackedFrames = subscription.Nack(id);
            var queue        = _queueRepository.Get(subscription.QueueName);

            foreach (var frame in nackedFrames)
            {
                //TODO: Should messages be put in front of the queue?
                queue.Enqueue(frame);
            }
        }