带 TransactionScope 的 Rebus 处理程序

发布于 2025-01-11 01:02:53 字数 1807 浏览 3 评论 0原文

我已经设置了一个 Rebus 处理程序,并将事务范围附加到 MSMQ 和 RabbitMQ。处理程序 100% 处理前几条消息。几分钟后,当我尝试向队列发布新消息时,我收到以下错误消息......

我做错了什么?


    [11:09:59 ERR] An error occurred when attempting to complete the transaction context
    System.Transactions.TransactionAbortedException: The transaction has aborted.
     ---> System.TimeoutException: Transaction Timeout
       --- End of inner exception stack trace ---
       at System.Transactions.TransactionStateAborted.BeginCommit(InternalTransaction tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState)
       at System.Transactions.CommittableTransaction.Commit()
       at System.Transactions.TransactionScope.InternalDispose()
       at System.Transactions.TransactionScope.Dispose()
       at Rebus.TransactionScopes.TransactionScopeTransportDecorator.<>c__DisplayClass7_0.<Receive>b__1(ITransactionContext ctx)
       at Rebus.Transport.TransactionContext.Dispose()
       at Rebus.Transport.TransactionContext.Complete()
       at Rebus.Workers.ThreadPoolBased.ThreadPoolWorker.ProcessMessage(TransactionContext context, TransportMessage transportMessage)

        // Initialize Class
        _activator = new BuiltinHandlerActivator();
        // Register
        _activator.Register((context, handler) => new Handler(_activator.Bus));
        
        // Configure
        Configure.With(_activator)
            .Logging(logging => logging.Serilog())
            .Options(options =>
            {
                options.HandleMessagesInsideTransactionScope();
                options.SimpleRetryStrategy(maxDeliveryAttempts: 1, secondLevelRetriesEnabled: true);
                options.SetMaxParallelism(5);
                options.SetNumberOfWorkers(5);
            })

I have setup a Rebus handler with a Transaction Scope attached to it to MSMQ and RabbitMQ. The handler handles the first few messages 100%. After a couple of minutes when I try publish new messages to the queue I get the error message below....

What am I doing wrong?


    [11:09:59 ERR] An error occurred when attempting to complete the transaction context
    System.Transactions.TransactionAbortedException: The transaction has aborted.
     ---> System.TimeoutException: Transaction Timeout
       --- End of inner exception stack trace ---
       at System.Transactions.TransactionStateAborted.BeginCommit(InternalTransaction tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState)
       at System.Transactions.CommittableTransaction.Commit()
       at System.Transactions.TransactionScope.InternalDispose()
       at System.Transactions.TransactionScope.Dispose()
       at Rebus.TransactionScopes.TransactionScopeTransportDecorator.<>c__DisplayClass7_0.<Receive>b__1(ITransactionContext ctx)
       at Rebus.Transport.TransactionContext.Dispose()
       at Rebus.Transport.TransactionContext.Complete()
       at Rebus.Workers.ThreadPoolBased.ThreadPoolWorker.ProcessMessage(TransactionContext context, TransportMessage transportMessage)

        // Initialize Class
        _activator = new BuiltinHandlerActivator();
        // Register
        _activator.Register((context, handler) => new Handler(_activator.Bus));
        
        // Configure
        Configure.With(_activator)
            .Logging(logging => logging.Serilog())
            .Options(options =>
            {
                options.HandleMessagesInsideTransactionScope();
                options.SimpleRetryStrategy(maxDeliveryAttempts: 1, secondLevelRetriesEnabled: true);
                options.SetMaxParallelism(5);
                options.SetNumberOfWorkers(5);
            })

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文