Use Bus.Send (not Publish) from web applications (NServiceBus v3.2.0.0)

筅森魡賤 提交于 2019-12-12 03:28:53

问题


We have an asp.net mvc3 application which publishes a number of events. Recently, someone pointed out that we should be sending messages rather than publishing events from the web application and referenced this excellent blog post which makes perfect sense. However, I want to confirm that the points made in the post are still valid for NServiceBus v3.x?

Thanks!


回答1:


I would imagine that the reasoning behind the post would always hold true, irrespective of the version of NServiceBus.

That being said, there is nothing stopping you from publishing a message from a web-site. The idea behind publishing a message is that the message represents an event that is typically produced by some processing endpoint. Since a web application should not really be processing anything but rather be sending commands off to a processing endpoint it would stand to reason that a web application should not be publishing events.

So if you find yourself in a situation where it seems to make sense to publish from your web application it indicates that you need to make a design decision: either the design is not optimal (so the web application is performing processing) or you are constrained in some way the prohibits the implementation of a processing endpoint (maybe a shared hosting environment).



来源:https://stackoverflow.com/questions/13565196/use-bus-send-not-publish-from-web-applications-nservicebus-v3-2-0-0

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