//验证Transaction internal void ValidateTransaction(ITransaction transaction) { IList<IMessage> children = transaction.Children; int len = children.Count; for (int i = 0; i < len; i++) { IMessage message = children[i]; var transaction1 = message as ITransaction; if (transaction1 != null) { ValidateTransaction(transaction1); } } if (!transaction.IsCompleted()) { // missing transaction end, log a BadInstrument event so that // developer can fix the code IMessage notCompleteEvent = new DefaultEvent("CAT", "BadInstrument") {Status = "TransactionNotCompleted"}; notCompleteEvent.Complete(); transaction.AddChild(notCompleteEvent); transaction.Complete(); } }
private void MarkAsNotCompleted(DefaultTransaction transaction) { IEvent notCompleteEvent = new DefaultEvent("CAT", "BadInstrument") { Status = "TransactionNotCompleted" }; notCompleteEvent.Complete(); transaction.AddChild(notCompleteEvent); transaction.Complete(); }
internal void LinkAsRunAway(IForkedTransaction transaction) { var @event = new DefaultEvent(PureCatConstants.TYPE_REMOTE_CALL, "RunAway"); @event.AddData(transaction.ForkedMessageId, $"{transaction.Type}:{transaction.Name}"); @event.Timestamp = transaction.Timestamp; @event.Status = PureCatConstants.SUCCESS; @event.Complete(); transaction.Standalone = true; _manager.Add(@event); }
internal void LinkAsRunAway(DefaultMessageManager manager, IForkedTransaction transaction) { IEvent @event = new DefaultEvent(PureCatConstants.TYPE_REMOTE_CALL, "RunAway"); @event.AddData(transaction.ForkedMessageId, string.Format("{0}:{1}", transaction.Type, transaction.Name)); @event.Timestamp = transaction.Timestamp; @event.Status = PureCatConstants.SUCCESS; @event.Complete(); transaction.Standalone = true; manager.Add(@event); }
public override void Complete() { try { if (IsCompleted()) { // complete() was called more than once IMessage evt0 = new DefaultEvent("cat", "BadInstrument") { Status = "TransactionAlreadyCompleted" }; evt0.Complete(); AddChild(evt0); } else { _mDurationInMicro = MilliSecondTimer.UnixNowMicroSeconds() - TimestampInMicros; SetCompleted(true); if (_mManager != null) { _mManager.End(this); } } } catch (Exception ex) { Cat.lastException = ex; } }