After a lot more digging, I've found what's really going on. I'm using Spring 2.5.6, Camel 2.2.0, ActiveMQ 5.3.1, Hibernate 3.4.0.GA, and Bitronix 1.3.3. The latest problem I was having (commit() call fails) was because Hibernate flushes itself to the DB as a pre-commit synchronization listener. If I manually called em.flush() the PK violation would be thrown in my application code and the Camel onException handlers would perform as expected. However, I decided that would not be a good way to go forward (what if the commit failed for some other reason?) and was left still searching for a solution.
Since almost all of my routes start with a JMS queue, I decided to actually use the XA functionality in the software I'm using and let any exception cause a rollback all the way to ActiveMQ. After a certain number of rollbacks, ActiveMQ will move the message to a DLQ. I've added a route that reads from the DLQ and does more or less the exact same actions my previous onException error handler did, but surrounded with a try/catch to prevent any errors in the DLQ route from causing an infinite loop. This seems more like an "enterprise" solution, and I probably should have used it from the beginning. Thanks for all your help Claus! Claus Ibsen-2 wrote: > > On Wed, Apr 14, 2010 at 6:51 PM, dnn <[email protected]> wrote: >> >> This one just won't die :) >> >> I've got the same issue, but caused in a slightly different way. The >> problem is when the DB commit fails (in my case, a unique constraint >> violation to an Oracle DB), the commit happens outside of the >> TransactionErrorHandler.super.process(exchange) block, and won't trigger >> the >> global onException handlers. >> > > That is painful, the Oracle JDBC drivers is really bad. > You can try with XA to have both JMS + JDBC in the same orchestrated TM. > >> I've tried to create a unit test to show the issue, but I cannot figure >> out >> how to make HSQL throw an exception at commit time. If anyone has any >> tips >> I'd be happy to create a unit test. >> > > Maybe some mock frameworks can do this. > > -- View this message in context: http://old.nabble.com/onException-handling-tp28183226p28267409.html Sent from the Camel - Users mailing list archive at Nabble.com.
