简体   繁体   English

SQL Service Broker排队等候

[英]SQL Service Broker Peek on queue

I'm writing a C# application that uses SSB queues to communicate with other systems. 我正在编写一个使用SSB队列与其他系统通信的C#应用​​程序。 When receiving a message from a SSB queue, I am not always sure I am able to handle it. 从SSB队列接收消息时,我并不总是确定自己能够处理该消息。 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. 因此,我想在队列偷看(或者也许只是被通知有一个信息,不是neccessarily它的内容),但在同一时间使用SSB语法,包括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. 这样做的原因是,我希望100%确保没有消息丢失,即使接收方遇到某种不可恢复的故障。 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. 如果有人有其他解决方案来确保不会丢失任何数据,我将不知所措。

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. 如果回滚该事务(或仅按预期方式在队列中进行窥视),您将最终遇到以下情况:队列中无法处理一条消息,并且无限期地继续窥视(或接收/回滚)该消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM