コード例 #1
0
        public async Task <SQueueData> Do(string key)
        {
            var queue = await _sQueueChooseService.Choose(key);

            if (queue == null)
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.NotFoundSQueueByMessageType,
                    DefaultFormatting = "消息类型为{0},但没有找到对应的队列",
                    ReplaceParameters = new List <object>()
                    {
                        key
                    }
                };

                throw new UtilityException((int)Errors.NotFoundSQueueByMessageType, fragment);
            }

            SQueueData data = new SQueueData()
            {
                GroupName  = queue.GroupName,
                ServerName = queue.ServerName,
                Name       = queue.Name,
                Code       = queue.Code
            };

            return(data);
        }
コード例 #2
0
ファイル: SMessage.cs プロジェクト: rhw1111/DCEM
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public async Task Add(SMessage message)
        {
            //根据key获取队列
            var queue = await _sQueueChooseService.Choose(message.Key);

            //执行存储
            await _smessageStore.Add(queue, message);

            //执行扩展
            var context = _smessageOperationContextFactory.Create(message, new Dictionary <string, object>());
            await MessageQueueExtensionDescription.OnSMessageAddExecuted(context);
        }