SqlServer可以触发推送到ActiveMQ [英] Can a SqlServer trigger push to ActiveMQ

查看:174
本文介绍了SqlServer可以触发推送到ActiveMQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我是否有可能将数据从SqlServer触发器直接推送到ActiveMQ。

can anyone tell me if it is possible to push data from a SqlServer trigger directly to ActiveMQ.

我搜寻了ActiveMQ文档,却没有看到引用它。我们可以使用轮询数据库的服务进行插入,但是触发器将是理想的解决方案。

I have hunted through the ActiveMQ docs and don't see any reference to it. We can use a service polling the DB for inserts but the trigger would be the ideal solution.

推荐答案


但是触发器将是理想的解决方案

but the trigger would be the ideal solution

绝对不是。造成这个主意不好的原因有很多,但我将主要介绍给您:

Absolutely not. There are many reasons why this is a bad idea, but I'll give you the main ones:


  • 在您添加每个DML时增加了延迟需要等待RPC调用完成。

  • ActiveMQ出现可用性问题时,操作会随机且不稳定地发生操作故障(RPC调用失败,并带有DML和原始应用程序事务)

  • 存在回滚的正确性。仅此一项就可以了。如果运行触发器的应用程序事务由于某种原因而回滚,则无法撤消ActiveMQ操作。

其中一些可以解决通过将应用程序事务与排队系统(即)一起注册到分布式事务(2PC)中。 ActiveMQ的XA 。这解决了最后一个问题,但以增加严重的延迟和将吞吐量减少几个数量级为代价。

Some of these can be solved by enrolling the app transaction in a distributed transaction (2PC) along with the queuing system, ie . XA for ActiveMQ. This solves the last problem but at the cost of adding serious latency and reducing the throughput by orders of magnitude.

提倡的解决方案是使触发器在<一个href = http://rusanu.com/2010/03/26/using-tables-as-queues/ rel = nofollow>用作队列的表,并使外部应用程序由此退出队列表并推送到ActiveMQ。不要走捷径,将应用程序状态用作队列(即,轮询状态并标记为已处理),这就是为什么数据库中的队列尝试中有99%失败的原因。

The advocated solution is to have the trigger enqueue locally in a table used as a queue and have an external application dequeue from this table and push to ActiveMQ. Do not cut corners and use your application state as the 'queue' (ie. poll the state and mark as 'processed'), this is why 99% of 'queue in the database' attempts fail.

您仍然无法解决从队列存储中拆分数据存储时固有的一些问题(无法进行一致的备份/恢复, HA / DR的故障转移时出现裂脑,因为队列未跟随数据库故障转移等),但是只有当您购买嵌入到数据库中的队列和消息传递时,这些问题才能解决,例如服务代理

You still won't be able to solve some of the issues that are inherent when you split your data storage from the queue storage (inability to do consistent backup/restores, 'split-brains' on failover for HA/DR as the queueing does not follow the database failover etc) but those can only be solved if you buy into queueing and messaging embeded in the database, like Service Broker.

这篇关于SqlServer可以触发推送到ActiveMQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆