Ejemplo n.º 1
0
        public async Task <PushResult> Push(QueueMessage message)
        {
            try
            {
                QueueClient cc;
                if (_queue.Options.Acknowledge == QueueAckDecision.WaitForAcknowledge)
                {
                    Tuple <QueueClient, int> tuple = await _queue.GetNextAvailableRRClient(_roundRobinIndex);

                    cc = tuple.Item1;
                    if (cc != null)
                    {
                        _roundRobinIndex = tuple.Item2;
                    }
                }
                else
                {
                    cc = _queue.GetNextRRClient(ref _roundRobinIndex);
                }

                /*
                 * //if to process next message is requires previous message acknowledge, wait here
                 * if (_queue.Options.Acknowledge == QueueAckDecision.WaitForAcknowledge)
                 *  await _queue.WaitForAcknowledge(message);
                 */

                if (cc == null)
                {
                    _queue.AddMessage(message, false);
                    return(PushResult.NoConsumers);
                }

                ProcessingMessage = message;
                PushResult result = await ProcessMessage(message, cc);

                ProcessingMessage = null;

                return(result);
            }
            catch (Exception e)
            {
                _queue.Server.SendError("PUSH", e, $"QueueName:{_queue.Name}, State:RoundRobin");
                return(PushResult.Error);
            }
        }