Ejemplo n.º 1
0
        /// <summary>
        /// 结束通知
        /// </summary>
        /// <param name="context"></param>
        /// <param name="success"></param>
        private void SagaSubError(BaseModule context)
        {
            context.Input.TryGetValue(GlobalTraceId, out string globalId);
            Dictionary <string, string> response = new Dictionary <string, string>();

            response.Add("globalTraceId", globalId);
            context.InvokeProcessor("Anno.Plugs.DTransaction", "DTransaction", "SagaSubError", response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 结束通知
        /// </summary>
        /// <param name="context"></param>
        /// <param name="success"></param>
        private void SagaEnd(BaseModule context, bool success)
        {
            context.Input.TryGetValue(GlobalTraceId, out string globalId);
            Dictionary <string, string> response = new Dictionary <string, string>();

            response.Add("globalTraceId", globalId);
            response.Add("sagaStartSuccess", success.ToString());
            context.InvokeProcessor("Anno.Plugs.DTransaction", "DTransaction", "SagaEnd", response);
        }
Ejemplo n.º 3
0
        /*
         * 事务开始前
         */
        public void OnActionExecuting(BaseModule context)
        {
            context.Input.TryGetValue(GlobalTraceId, out string globalId);
            Dictionary <string, string> response = new Dictionary <string, string>();

            response.Add("globalTraceId", globalId);
            response.Add("executionTimeSpan", (ExecutionSeconds * 1000).ToString());
            response.Add("recover", this.RecoverMethod);
            response.Add("sagaInput", JsonConvert.SerializeObject(context.Input));
            context.InvokeProcessor("Anno.Plugs.DTransaction", "DTransaction", "SagaStarted", response);
        }
Ejemplo n.º 4
0
 /*
  * 业务执行后
  */
 public void OnActionExecuted(BaseModule context)
 {
     if (context.ActionResult.Status)
     {
         context.Input.TryGetValue(GlobalTraceId, out string globalId);
         context.Input.TryGetValue(TraceId, out string traceId);
         Dictionary <string, string> response = new Dictionary <string, string>();
         response.Add("globalTraceId", globalId);
         response.Add("traceId", traceId);
         response.Add("recover", this.RecoverMethod);
         response.Add("sagaInput", JsonConvert.SerializeObject(context.Input));
         response.Add("sagaRlt", JsonConvert.SerializeObject(context.ActionResult));
         context.InvokeProcessor("Anno.Plugs.DTransaction", "DTransaction", "SagaSub", response);
     }
     else
     {
         SagaSubError(context);
     }
 }