gpt4 book ai didi

c# - 由 Bus.Publish() 或订阅引起的 StackOverflowException?

转载 作者:太空宇宙 更新时间:2023-11-03 22:04:58 24 4
gpt4 key购买 nike

我有一个代理,它使用传奇来跟踪给定类型的传入消息,直到收到超时消息。在超时处理程序中,我有以下内容:

public override void Timeout(object state)
{
// If Data.IsNull: Do nothing!!! Report to log only.
Logger.Debug("=========================================================================");
Logger.Debug(string.Format("Timeout message received. State: {0}.", state.ToString()));

QuickBatch qbBuilder = new QuickBatch();
// Create new message and publish it
BankRequestBatchClosed eventMessage = Bus.CreateInstance<BankRequestBatchClosed>();

eventMessage.UniqueBatchIdentifier = qbBuilder.GenerateUniqueBatchIdentifier(QuickBatch.QB_BATCHTYPE_CC);
eventMessage.ScheduleBatchID = this.Data.ScheduleBatchID;
eventMessage.EventDate = DateTime.Now;
eventMessage.EventID = Guid.NewGuid();
eventMessage.TransactionItems = this.Data.PaymentRequestedTransactionItems;

Logger.Debug("=========================================================================");
Logger.Debug(string.Format("Timeout method about to send BankRequestBatchClosed message. UniqueBatchIdentifier: {0}",eventMessage.UniqueBatchIdentifier));

Bus.Publish(eventMessage);
Complete();
}

TransactionItems 是一个 ICollection

这是 TransactionDetail 类:

   [Serializable]
public class TransactionDetail
{
// Guid needed for NHibernate to store it in database. All
// member variables are virtual for the same reason.
public virtual Guid Id { get; set; }
public virtual Int32 ScheduleBatchID { get; set; }
public virtual Int32 PseudoSagaID { get; set; }
public virtual String CreditCardNumber { get; set; }
public virtual String ExpiryDate { get; set; }

public virtual String AccountNumber { get; set; }
public virtual String BSB { get; set; }

public virtual Decimal Amount { get; set; }
public virtual Int32 Firm_fk { get; set; }
public virtual String FirmName { get; set; }
public virtual TransactionType PaymentType { get; set; }
// transaction number, max 15 chars, to use one of the following:
public virtual int ApplicationPaymentInfo_fk { get; set; }
public virtual BankRequestResponseSagaBase Parent { get; set; }
}

如果我没有任何订阅,Bus.Publish() 调用会正常进行。如果我订阅了其他服务,我会收到以下错误消息:

在 mscorlib.dll 中出现类型为“System.StackOverflowException”的未处理异常

除此之外没有关于溢出的更多信息:{无法计算表达式,因为当前线程处于堆栈溢出状态。}

我有自己的 SagaPersister、Profile 和 SagaRegistry,但不确定它们是否与这个问题相关,但如果需要可以提供。

最佳答案

这里看起来有点可疑的是 TransactionDetail 对象上的 BankRequestResponseSagaBase Parent 属性。可能是你的引用中有一个循环导致你的 saga 持久化器爆炸。

关于c# - 由 Bus.Publish() 或订阅引起的 StackOverflowException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8784652/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com