“IsTransactional"是什么意思?在 NServiceBus 中是什么意思? [英] What does "IsTransactional" in NServiceBus mean?

查看:123
本文介绍了“IsTransactional"是什么意思?在 NServiceBus 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 Web 应用程序,该应用程序将使用 NServiceBus 发送 消息,并写入数据库.我希望这是一个原子操作,即一个事务,所以我将代码包装在一个 using new TransactionScope() 语句中.

I am creating a web application that is going to send messages using NServiceBus, and also write to a database. I want this to be an atomic operation, i.e. a transaction, so I wrap the code in a using new TransactionScope() statement.

在配置 NServiceBus 时,您可以调用 IsTransactional 方法.我什么时候将 'false' 传递给这个方法,什么时候传递 'true' 合适?

When configuring NServiceBus you can call the IsTransactional-method. When do I pass 'false' to this method, and when is 'true' appropriate?

推荐答案

IsTransactional(true) 表示所有传入消息都将在一个事务范围内处理

IsTransactional(true) mean that all incoming messages will be processed within a transactionscope

http://docs.particular.net/nservicebus/architecture/http://docs.particular.net/nservicebus/architecture/principles

对于发送(传出消息),您需要创建自己的事务范围以确保与数据库一致.通常将实际处理(如写入数据库)移动到后端进程是个好主意.如果您这样做,NServiceBus 将为您处理重试、异常管理等.

For sends (outgoing messages) you need to create your own transaction scope to make sure that you're consitent with your database. Usually it's a good idea to move the actual processing (like writing to the database) to backend processes. If you do that NServiceBus will handle things like retries, exception management etc for you.

更多关于这里的信息:

http://www.make-awesome.com/2010/10/why-not-publish-nservicebus-messages-from-a-web-application/

这篇关于“IsTransactional"是什么意思?在 NServiceBus 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆