javaapache-cameljbossfuseapache-servicemixfuseesb

Apache Camel - JDBC Stored Procedures and transaction handling doubts


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:

  1. JMS text message comes in
  2. I have to execute a series of database operations based on the message content, invoking mainly stored precedures/functions
  3. from the results acquired by the db calls I have to construct a reply message and send it to specific jms queue.
  4. 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.


Solution

  • 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.