简体   繁体   English

我可以确保SQL Service Broker中对话对话的顺序吗?

[英]Can I ensure the order of dialog conversations in sql service broker?

So, I've got an 'A' server and a 'B' server. 因此,我有一个“ A”服务器和一个“ B”服务器。 We are using SQL Service Broker to perform replication. 我们正在使用SQL Service Broker执行复制。 An application we have will need to write data to either the 'A' server, or the 'B' server. 我们拥有的应用程序需要将数据写入“ A”服务器或“ B”服务器。 (one may be down, and the other one should take over) (一个可能已关闭,另一个应接管)

Data is written to the database only within stored procedures, which are wrapped in a transaction to keep the data in the tables consistent. 数据仅在存储过程中被写入数据库,存储过程被包装在事务中以使表中的数据保持一致。

One of these transactions will include all of the messages to be sent to the peer server. 这些事务之一将包括要发送到对等服务器的所有消息。 So, in my application code, when I attempt to commit a transaction, it should write all of the data to the tables, and send the messages to the peer server. 因此,在我的应用程序代码中,当我尝试提交事务时,它应该将所有数据写入表,并将消息发送到对等服务器。

However, if the peer server is down, then the messages will wait in sys.transmission_queue. 但是,如果对等服务器已关闭,则消息将在sys.transmission_queue中等待。

Message order within a dialog conversation is guaranteed, but can I ensure that dialog conversations will be processed in the order that I created them? 对话对话中的消息顺序是可以保证的,但是我可以确保对话对话将按照创建对话的顺序进行处理吗?

For example, I could have a problem if the 'B' server is down, A user writes data to the 'A' server. 例如,如果“ B”服务器关闭,我可能会遇到问题,用户将数据写入“ A”服务器。 Once the 'B' server is back up again, if those dialog conversations are processed out of order, they may not work correctly. 再次备份“ B”服务器后,如果这些对话会话未按顺序处理,则它们可能无法正常工作。 (They could try to insert data with a bad foreign key, or something like that). (他们可以尝试使用错误的外键或类似的东西插入数据)。

I am working under the following assumptions: 我正在以下假设下工作:

  1. I should have a single dialog conversation for each transaction. 我应该为每个事务进行一次对话。

  2. The form of the solution must be as replication by way of sql service broker. 解决方案的形式必须是通过sql服务代理进行复制。 (This is done in other parts of the database, so any reason to use an alternate strategy must be compelling). (这是在数据库的其他部分完成的,因此使用替代策略的任何理由都必须具有吸引力)。

You should user Broker Priority. 您应该使用“代理优先级”。 http://msdn.microsoft.com/en-us/library/bb934170.asp http://msdn.microsoft.com/en-us/library/bb934170.asp

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

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