数据库触发器和JMS [英] Database Trigger And JMS

查看:191
本文介绍了数据库触发器和JMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Cound我创建了一个触发器来向JMS发送一条记录消息?如果是,我该怎么办?
提前感谢!

Cound I create a trigger to send a record message to JMS? If yes, how can I do? Thanks in advance!

推荐答案

我将总结以下选项:

支持JMS的数据库

Oracle是我所知道的唯一支持JMS的数据库, a href =http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96587/qintro.htm> Oracle高级队列。如果您的消息接收者不太热衷于JMS实现,通常可以找到某种消息桥,将消息从一个JMS实现转换并转发到另一个JMS实现。例如:

Oracle is the only database that I am aware of that supports JMS natively in the form of Oracle Advanced Queueing. If your message receiver is not too keen on that JMS implementation, it is usually possible to find some sort of messaging bridge that will transform and forward messages from one JMS implementation to another. For example:

  • Apache Active MQ
  • JBoss Messaging

支持Java的数据库

某些数据库,例如 Oracle 和< a href =https://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.sql.doc/doc/c0006348.htm> DB2 具有内置的Java虚拟机,并支持加载第三方库(Jars)和可由触发器代码调用的自定义类。根据您的JMS客户端的要求,这是一个问题,由于Java支持的版本(如果您需要Java 5+,但DB只支持Java 3)。另请注意,其中一些嵌入式JVM中的线程是不是您的可能期望它是,但是,也可以期望发送JMS消息可能比接收相同的更宽容。

Some databases such as Oracle and DB2 have a built in Java Virtual Machine and support the loading of third party libraries (Jars) and custom classes that can be invoked by trigger code. Depending on the requirements of your JMS client, this be an issue on account of the version of Java supported (if you need Java 5+ but the DB only supports Java 3). Also keep in mind that threading in some of these embedded JVMs is not what you might expect it to be, but, one might also expect that the sending of JMS messages might be more forgiving of this than the receiving of the same.

支持外部调用(但不支持Java)的数据库

多个数据库支持将异步事件触发到连接的客户端,根据事件的有效内容构建的JMS消息:

Several databases support different means of triggering asynchronous events out to connected clients which can in turn forward JMS messages built from the payload of the event:

  • Oracle: DBMS_ALERT (synchronous), DBMS_PIPE, DCN
  • Postgres: SQLNotify

某些数据库(以上所有,包括 SQLServer )允许您从数据库过程代码被触发器调用)。虽然它不是JMS,邮件侦听器可能侦听邮件消息(可能方便地有一个JSON或XML消息体),并将此内容转发为JMS消息。

Some databases (all of the above and including SQLServer) allow you to send SMTP messages from database procedural code (which can be invoked by triggers). While it is not JMS, a mail listener could potentially listen for mail messages (that might conveniently have a JSON or XML message body) and forward this content as a JMS message.

这是一个基本的替代方法是允许HTTP帖子调用外部源的数据库包,您可能有一个servlet监听并将提交的内容作为JMS消息转发。

A basic alternate of this is databases packages that allow HTTP posts to call out to external sources where you might have a servlet listening and forwarding the submitted content as a JMS message.

其他数据库(如Postgres)支持非java语言,例如 Perl Python Tcl ,您可以使用一些聪明的脚本将消息发送到将作为JMS转发的外部消息转换器。活动MQ(及其消息桥)支持多语言JMS客户端,其中包括 Python Perl (和许多其他)。

Other databases such as Postgres support non-java languages such as Perl, Python and Tcl where you might employ some clever scripting to send a message to an external message transformer that will forward as JMS. Active MQ (and therefore its message bridge) supports a multi-language JMS client that includes Python and Perl (and many others).

最低公分母

可以向表中写入事件,外部客户端可以轮询表的内容,在发现JMS消息时查找新数据和转发JMS消息。 JMS消息可以包括内容,或者简单地指示内容存在以及PK是什么,消费者可以得到它。

Short of all that, your trigger can write an event to a table and an external client can poll the contents of the table, looking for new data and forwarding JMS messages when it finds it. The JMS message can either include the content, or simply indicate that content exists and what the PK is, and the consumer can come and get it.

这是一种广泛使用的技术在 Apache Camel 中支持,其中包含专门用于轮询数据库的适配器(技术上称为组件):

This is a technique widely supported in Apache Camel which has adapters (technically called Components) specifically for polling databases:

  • Hibernate
  • JDBC
  • SQL
  • iBatis

然后可以将Camel从数据库表中读取的事件转换并路由到各种目标,包括 JMS 服务器(以JMS消息的形式)。实施这个骆驼是相当直接和有据可查的,所以这不是一个坏的方式去。

Events read from a database table by Camel can then be transformed and routed to a variety of destinations including a JMS server (in the form of a JMS message). Implementing this Camel is fairly straight forward and well documented, so this is not a bad way to go.

我希望这是有帮助的。

这篇关于数据库触发器和JMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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