SQL Service Broker 查看队列
我正在编写一个使用 SSB 队列与其他系统通信的 C# 应用程序。 当从 SSB 队列接收消息时,我并不总是确定自己能够处理它。因此,我想查看队列(或者可能只是被通知有a消息,不一定是内容),但同时使用SSB语法,包括WAITFOR。
这样做的原因是我希望 100% 确定不会丢失任何消息,即使接收者遇到某种不可恢复的故障也是如此。另一种解决方案可能是将其包装在事务中,但这将需要更多的代码更改,而不仅仅是查看调用。如果有人有任何替代解决方案来确保不丢失数据,我会洗耳恭听。
I'm writing a C# application that uses SSB queues to communicate with other systems.
When receiving a message from a SSB queue, I am not always sure I am able to handle it. Therefore I would like to peek at the queue (or maybe just being notified that there is a message, not neccessarily it's content), but at the same time using the SSB syntax, including WAITFOR.
The reason to do this is that I want to be 100% sure that no message ever get lost, even if the receiver experiences some kind of irrecoverable failure. Another solution might be to wrap it up in a transaction, but this would require much more code changes than just a peek call. If anyone has any alternative solution to ensure that no data get lost, I am all ears.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该先收到消息,然后再决定是否可以处理它。如果不能,“写一条日志消息并退出” - 但提交接收事务。如果您回滚事务(或者只是按照您的意图查看队列),您最终会遇到这样的情况:队列中存在您无法处理的消息,并且您会无限期地继续查看(或接收/回滚)它。
You should first receive the message and then decide whether or not you can handle it. If you can't, "write a log message and bail out" - but commit the receive transaction. If you rollback the transaction (or just do peek on the queue as you intended to) you will end up in a situation where there's a message you cannot handle in the queue and you keep peeking (or receiving/rolling back) it indefinitely.