コード例 #1
0
ファイル: ESGrain.cs プロジェクト: lineCode/Ray
        protected virtual async Task AfterEventSavedHandle(IEventBase <K> @event, byte[] bytes, int recursion = 0, string hashKey = null)
        {
            try
            {
                if (string.IsNullOrEmpty(hashKey))
                {
                    hashKey = GrainId.ToString();
                }
                //消息写入消息队列
                await MQService.Publish(@event, bytes, hashKey);

                //更改消息状态
                await EventStorage.CompleteAsync(@event);
            }
            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 AfterEventSavedHandle(@event, bytes, newRecursion, hashKey : hashKey);
            }
        }
コード例 #2
0
ファイル: ESGrain.cs プロジェクト: zmk523/Ray
 protected virtual async Task AfterEventSavedHandle(IEventBase <K> @event, byte[] bytes, string hashKey = null)
 {
     try
     {
         if (string.IsNullOrEmpty(hashKey))
         {
             hashKey = GrainId.ToString();
         }
         //消息写入消息队列
         if (PublishEventToMq)
         {
             await MQService.Publish(@event, bytes, hashKey);
         }
         //更改消息状态
         await EventStorage.CompleteAsync(@event);
     }
     catch (Exception e)
     {
         Logger.LogError(LogCodes.EventCompleteError, e, "事件complate操作出现致命异常:" + string.Format("Grain类型={0},GrainId={1},StateId={2},Version={3},错误信息:{4}", ThisType.FullName, GrainId, @event.StateId, @event.Version, e.Message), null, e);
         throw e;
     }
 }