在 SQL Server 中为 webhook 添加表触发器

Pep*_*Pep 6 sql-server triggers

第三方应用程序使用 MS SQL Server 作为数据存储。在第 3 方应用程序 API 中,他们忘记为事件添加 webhooks,所以我试图通过在他们的 SQL Server 数据库上添加相关表触发器来在他们的 API 中添加 webhooks 的概念。

这个想法是使用表触发器捕获 UPDATE 事件,如果它们更改给定字段,则通知进程(在 SQL Server 框之外)执行一些批处理操作。

我正在考虑让 SQL Server 以某种方式调用 URL(也称为“webhook”)而不等待响应(或立即超时),最好使用 T-SQL。

有没有办法在 SQL Server 中做到这一点(来自 T-SQL 的异步 URL 调用),或者与外部系统通信而不会意外锁定 SQL Server 的唯一安全方法是从 SQL Server 发送电子邮件?(我使用的是 SQL Server 2012)

Dav*_*oft 5

有什么方法可以在 SQL Server 中做到这一点(来自 T-SQL 的异步 URL 调用)

不可以。您必须写入表或 Service Broker 队列,并使用异步处理来自该表或队列的通知。

You can use a simple table for that with a polling process, or use Service Broker (Database Mail, Event Notifications, and Query Notifications all use Service Broker).

Service Broker Internal Activation enables you to register a stored procedure that will be run by a background process whenever there are messages in a queue. You can block this background process with long-running tasks without interfering with the application workload. You can also process the queued messages with an external application.