我有一个代理使用 saga 来跟踪给定类型的传入消息,直到收到超时消息。在超时处理程序中,我有以下内容:
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”类型的未处理异常
除此以外没有关于溢出的更多信息:{Cannot evaluate expression because the current thread is in a stack overflow state.}
我有自己的 SagaPersister、Profile 和 SagaRegistry,但不确定它们是否与此问题相关,但如果需要可以提供。