简体   繁体   English

SQL Server Broker:如何修改合同?

[英]SQL Server Broker: How to modify contract?

How do I add a new message type to an existing contract? 如何在现有合同中添加新的消息类型?

CREATE CONTRACT and DROP CONTRACT commands exist, but no ALTER command. 存在CREATE CONTRACTDROP CONTRACT命令,但没有ALTER命令。

ALTER CONTRACT is not amiss due to omission, is missing by design . 由于遗漏, ALTER CONTRACT无效,设计上遗漏了该内容 This is exactly like asking to change COM interfaces: is not supported, because the interface is a contract . 这就像要求更改COM接口:不支持,因为该接口是一个contract If one party changes the interface, it breaks the contract and will cause the other party to crash when calling the wrong v-table entry. 如果一方更改了接口,则会破坏合同,并在调用错误的v-table条目时导致另一方崩溃。 Exactly the same reasoning was applied in Service Broker design: one party cannot change ( ALTER ) the contract and start sending some new messages the other party does not expect, it will cause it to crash (error in the message processing procedure). 在Service Broker设计中使用了完全相同的推理:一方无法更改( ALTER )合同并开始发送另一方不希望的新消息,这将导致它崩溃(消息处理过程中的错误)。 Contracts are immutable . 合同是一成不变的

If you say 'but I can ALTER the other party too' then you are not considering real use cases, when the other party is remote and often under a different administrative control and not willing to change its contract(s). 如果您说“但我也可以ALTER另一方”,那么您就不在考虑真实的用例,因为另一方是远程的,通常处于不同的管理控制之下,不愿意更改其合同。 even when a change is possible, deploying a distributed change that requires many side to roll out new bits is just asking for (unnecessary!) downtime. 即使有可能进行更改,部署需要许多方面才能推出新功能的分布式更改也只是要求停机(不必要!)。

Changes in communication pattern must be deployed as new contracts. 通信模式的更改必须作为合同部署。 Services can implement multiple contracts, and adding a new contract to a service (via ALTER SERVICE ) is supported. 服务可以实现多个合同,并增加了新的合同服务(通过ALTER SERVICE支持。 Changes in distributed apps are rolled out by deploying new contract(s) while still supporting old one(s), then retiring old contract(s) (ie. overlap ). 通过在仍然支持旧合同的同时部署新合同来推出分布式应用程序中的更改,然后淘汰旧合同(即重叠 )。

From here :- 这里

A poor workaround to this would be to version all changes as new contracts but that would require an additional service and queue and existing conversations would not be able to benefit from the new message type. 不良的解决方法是将所有更改版本化为新合同,但这将需要额外的服务和队列,并且现有对话将无法从新消息类型中受益。

I highly recomend support for an alter contract command but also add support for SSDT to issue an alter command instead of drop/create. 我强烈建议您支持alter contract命令,但同时也增加了对SSDT的支持,以发出alter命令而不是drop / create。

I highly reconsideration of this request. 我高度重视此要求。 Or at a minimum: Add a check and error message to be raised from SSDT whenever any conversation exists that uses that service and/contract before dropping in a similar way that SSDT checks for existing data in a table before dropping said table. 或至少是:在删除之前,只要存在使用该服务和/合同的任何对话,就添加一条从SSDT发出的检查和错误消息,类似于在删除所述表之前,SSDT在表中检查现有数据。 This would at least help raise awareness of this side-effect and would have prevented deployment headaches. 这至少将有助于提高对这种副作用的认识,并避免部署方面的麻烦。

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

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