Exemplo n.º 1
0
        /// <summary>
        /// 生产消息
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns></returns>
        Task <IMessageResult> IMessagePoster.Post(IInlineMessage message)
        {
            message.Offline();
            var item = new ConsulQueueItem
            {
                ID   = message.ID,
                Name = message.Topic,
            };

            message.ID    = null;
            message.Topic = null;
            message.Trace = null;
            item.Message  = SmartSerializer.SerializeMessage(message).ToUtf8Bytes();
            redisQueues.Enqueue(item);
            semaphore.Release();
            message.RealState = MessageState.AsyncQueue;
            LogRecorder.MonitorDetails("[ConsulPoster.Post] 消息已投入发送队列,将在后台静默发送直到成功");
            return(Task.FromResult <IMessageResult>(null));//直接使用状态
        }