Apache Camel - JDBC存储过程和事务处理疑惑
我正在尝试构建一个小型的、概念验证的、基于 Camel 的应用程序(在 FuseESB 上运行),它可能会取代我们基于 EJB 构建的现有集成系统的一部分。 现在,我正在尝试找出使用 apache Camel 处理以下场景的最佳方法:
- JMS 文本消息传入
- 我必须根据消息内容执行一系列数据库操作,调用主要存储的过程/
- 函数数据库调用获取的结果我必须构造一条回复消息并将其发送到特定的 jms 队列。
- 如果出现错误/异常,我想使用死信通道处理机制。
我可以构建简单的camel路由,在camel中处理错误和异常看起来也很容易,我不明白的是如何使用Camel SQL组件(我知道JDBC组件不能是事务客户端)来使我的所有数据库调用作为一部分的单笔交易。据我在网上发现的 Camel SQL 组件不能用于执行存储过程 - 这是真的吗?如果是,我应该使用处理器还是简单的 pojo 类来执行 jdbc 调用?使用 pojo 或处理器类型的情况下事务怎么样?我非常感谢任何指向描述如何处理此类用例的资源的指针。
I'm trying to build a small, proof of concept, Camel based application (running on FuseESB) which will possibly replace part of our existing integration system build on EJB's.
Right now, I'm trying to figure out the best way to handle the following scenario with apache camel:
- JMS text message comes in
- I have to execute a series of database operations based on the message content, invoking mainly stored precedures/functions
- from the results acquired by the db calls I have to construct a reply message and send it to specific jms queue.
- In case of an error/exception I would like to use a dead letter channel handling mechanism.
I can build simple camel routes, handling errors and exceptions in camel looks easy too, what I don't get is how to use Camel SQL component (I understand that JDBC component cannot be a transactional client) to make all my db calls as part of single transaction. From what I found on the net Camel SQL component cannot be used to execute stored procedures - is it true? If it is, should I use Processors or simple pojo classes to do my jdbc calls? What about transactions in the case of using pojo or processor types? I would highly appreciate any pointers to resources describing how to handle such a use case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 Java Bean 进行 JDBC 交互,因为您想要进行多个调用并使用存储过程。有时 Java 代码更容易。
例如,Spring JdbcTemplate 对 JDK JDBC API 有很好的抽象,使得调用存储过程变得相当容易。
MyBatis 也支持调用存储过程。
http://loianegroner.com/2011/03/ibatis- mybatis-working-with-stored-procedures/
还有一个camel-mybatis组件。
I would suggest to use a Java Bean to do the JDBC interaction, since you want to do multiple calls and use stored procedures. Sometimes Java code is easier.
For example the Spring JdbcTemplate have a good abstraction over the JDK JDBC API and makes it fairly easy to call stored procedures.
Alternative then MyBatis have support for calling stored procedures as well.
http://loianegroner.com/2011/03/ibatis-mybatis-working-with-stored-procedures/
And there is a camel-mybatis component as well.