MSMQ 作为 SQL Server 插入的缓冲区

发布于 2024-11-30 05:18:23 字数 221 浏览 1 评论 0原文

我正在学习 MSMQ,并成功使用它对来自面向消费者的 ASP.NET MVC 网站的电子邮件和文本消息进行排队,由单独的客户端应用程序处理。

如果缺少 SQL Server 数据库,也许在交换驱动器或损坏的数据库部署时,将非时间关键型插入放入本地 MSMQ 队列中以提高正常运行时间是否有意义?

理论上,我可以在进行数据库更改时暂停/恢复队列处理(持久性)。有没有人尝试过这个或者有更好的方法吗?

I'm learning about MSMQ and am successfully using it to queue email and text messages from a consumer-facing ASP.NET MVC website, to be handled by a separate client application.

In the event of a missing SQL Server database, perhaps while swapping drives or a broken database deploy, would it make sense to queue non time-critical inserts in a local MSMQ queue to improve up-time?

Theoretically, I can then pause/resume queue processing (persistence) while making database changes. Has anyone tried this or is there a better way?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

黑凤梨 2024-12-07 05:18:23

If you're looking at higher availability by queueing locally then you should consider Service Broker deployed on SQL Express instances collocated with your IIS/ASP instance. The advantage of using SSB over MSMQ is that you have consistency between your message store and your data store (one consistent backup/restore, one consistent failover unit), it does scale much better than MSMQ under load, it does not require tw-phase-commit DTC to coordinate the MSMQ dequeue with the DB insert (can use one local DB transaction to dequeue/insert), it offers queryability of the pending messages (SELECT .. FROM queue), is integrated with the DB HA/DR solution (cluster failover/mirroring), you get DB contained activation and it all works from the familiar T-SQL programming environment. MSMQ's main advantage is support of a client side C#/.Net API.

过度放纵 2024-12-07 05:18:23

我所在的团队为了保证交付而实施了这一点。我们使用 MSMQ 将插入请求转发到数据库服务器,数据库服务器运行着自己的服务,该服务使请求出队并运行插入,然后确认消息(以确保传递)。它已经运行了一年多了,我们从未被要求找出它不起作用的原因......对我来说似乎很可靠。

I was on a team that implemented this for purposes of guaranteed delivery. We used MSMQ to forward the insert requests to the database server, which had its own service running that dequeued the requests and ran the inserts, then acknowledged the message (to ensure delivery). It's been running for over a year now, and we've never been asked to come figure out why it isn't working...seems pretty solid to me.

等你爱我 2024-12-07 05:18:23

这是非常主观的,因为它取决于您的应用程序的用途和方式。一般来说,像 MSMQ 这样的东西不用于此目的,而是您希望在您选择的数据库上设置某种高可用性集群。在大多数情况下,数据库完全关闭的情况很少见,对于大多数 LOB 应用程序来说,这通常是一个更大的问题,而不仅仅是在数据库因某种原因关闭时存储输入的数据。

还有一些开销需要考虑。对数据库的 INSERT 操作相对较快(在更大的方案中);将序列化的某物写入队列并让某物拾取它并执行插入操作会给您的应用程序增加大量滞后,更不用说以下事实:您必须考虑到现在一切都是异步的这一事实。

也就是说,MSMQ可以用于确保将内容从应用程序的一端传送到另一端,因此我认为在某些情况下这种情况可能是理想的。大多数时候,您最好信任您的数据库并使用 MSMQ 来启用异步处理并执行进程间和机器间通信。

This is very subjective because it depends on what your application does and how. Generally, something like MSMQ is not used for this purpose, rather you want to set up some kind of high-availability clustering on your database of choice. The occurrence of a database going completely down is rare in most cases, and generally a bigger problem for most LOB applications than just having somewhere to store data entered while the DB is down for whatever reason.

There's also overhead to think about. An INSERT operation to a database is relatively quick (in the larger scheme of things); writing a serialized something into a queue and having something pick it up and do that insert operation is going to add large amounts of lag to your application, not to mention the fact that you'll have to account for the fact that now everything is asynchronous.

That said, MSMQ can be used to ensure delivery of stuff from one end of an application to another, so I suppose there are instances where this scenario might be desirable. Most of the time though you're just better off trusting your DB and using MSMQ to enable asynchronous processing and performing interprocess and intermachine communication.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文