Пример #1
0
        private async Task EventInsertAfterHandle(IEventBase <K> @event, byte[] bytes, int recursion = 0, string mqHashKey = null)
        {
            try
            {
                if (SendEventToMQ)
                {
                    if (string.IsNullOrEmpty(mqHashKey))
                    {
                        mqHashKey = GrainId.ToString();
                    }
                    //消息写入消息队列
                    await MQService.Send(@event, bytes, mqHashKey);
                }
                //更改消息状态
                await EventStorage.Complete(@event);

                //保存快照
                await SaveSnapshotAsync();
            }
            catch (Exception e)
            {
                if (recursion > 5)
                {
                    throw e;
                }
                this.GetLogger("Event_Raise").Log(LogCodes.EventCompleteError, Orleans.Runtime.Severity.Error, "事件complate操作出现致命异常:" + string.Format("Grain类型={0},GrainId={1},StateId={2},Version={3},错误信息:{4}", ThisType.FullName, GrainId, @event.StateId, @event.Version, e.Message), null, e);
                int newRecursion = recursion + 1;
                await Task.Delay(newRecursion * 200);
                await EventInsertAfterHandle(@event, bytes, newRecursion, mqHashKey : mqHashKey);
            }
        }