Sharing JMS and Hibernate transactions in a Spring MDB using Oracle Streams AQ? Sharing JMS and Hibernate transactions in a Spring MDB using Oracle Streams AQ? oracle oracle

Sharing JMS and Hibernate transactions in a Spring MDB using Oracle Streams AQ?


2PC shouldn't be necessary, as you say, since the appserver should take care of it. However, you'll pretty much have to use JTA (i.e. JavaEE container) transactions, rather than vanilla DataSource transactions, since JMS only works with JTA.

This isn't a big deal, it's just a bit more fiddly:

  1. Your Spring config should use<jee:jndi-lookup/> to get areference to your container'sDataSource, and you inject thatdata source into your spring-managedhibernate SessionFactory.
  2. You then need to introduce a transaction manager into the context (<tx:jta-transaction-manager/> should work in most app-servers).
  3. In your Spring JMS MessageListenerContainer, plug the above transaction manager reference into it.

Does that all make sense, or should I elaborate? This setup should ensure that the container-managed transactions are held across JMS and Hibernate interactions.