Example #1
0
        /// <summary>
        /// 接收消息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="channel"></param>
        /// <param name="received"></param>
        /// <param name="queueName"></param>
        public static void Receive <T>(this Channel channel, Action <T, BasicDeliverEventArgs> received, string queueName)
        {
            var messageStructure = MemoryMap.GetMessageStructure(queueName: queueName);

            if (messageStructure == null)
            {
                throw new Exception("队列不在映射中!");
            }
            var queue = messageStructure.Queue;

            if (queue.Retry)
            {
                ReceiveRetryMode <T>(channel, received, messageStructure);
            }
            else if (queue.DeadLetter)
            {
                ReceiveDeadLetterMode <T>(channel, received, messageStructure);
            }
            else
            {
                ReceiveNormal <T>(channel, received, messageStructure);
            }
        }