What does “IsTransactional” in NServiceBus mean?

筅森魡賤 提交于 2019-12-11 05:36:06

问题


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.

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


回答1:


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

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.

More about that here:

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



来源:https://stackoverflow.com/questions/8168673/what-does-istransactional-in-nservicebus-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!