有没有可能用骆驼监听 sql 表/字段? [英] Is there any possibility to listen on an sql table/field with camel?

查看:31
本文介绍了有没有可能用骆驼监听 sql 表/字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一个用骆驼构建的网络服务,并在 karaf 上作为 OSGi 包运行.

I got a web service built with camel and running as an OSGi bundle on karaf.

当我在这里收到请求时,我将请求中的数据存储在 MySQL 数据库中.在此之后,另一个包必须检索数据,对其进行处理,然后更新数据集并在完成后立即将其标记为已在数据库中处理.然后第一个包必须再次检索处理/更改的数据,并将其作为对原始请求的响应发送.

When I get a request here I store the data from the request in a MySQL database. After this another bundle has to retrieve the data, do something with it and then update the dataset and mark it as processed in the db as soon as it is done. Then the first bundle got to retrieve the processed/changed data again the send it as a repsonse to the original request.

这里的问题是我需要对数据库中的数据进行某种监听,因为整个过程必须尽可能快(用户正在等待答案).

The problem here is that I need some kind of listener on that data in the db because the whole thing has to be as fast as possible (user is waiting for the answer).

有没有办法解决这个问题?每 x 秒/毫秒对表进行一次查询真的很脏...

Is there any possibility to solve this? Doing a query on the table every x seconds/milliseconds is really dirty...

推荐答案

有一些例子可以证明这一点,例如使用 MyBatis 或 SQL 组件

There is some examples that demonstrate this, for example using the MyBatis or SQL component

您也可以像 Christian 所说的那样使用 JPA.

You can also use JPA as Christian says.

没有使用一些 MySQL 原生 API 来监听事件的特殊 MySQL 组件.我不知道是否有任何这样的 API.Camel 中的组件是执行 SQL SELECT 的通用 JDBC/SQL 组件.

There is no special MySQL component that uses some MySQL native API for listening on events. I am not aware if there is any such API. The components in Camel are generic JDBC/SQL components that does a SQL SELECT.

这篇关于有没有可能用骆驼监听 sql 表/字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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