Hi, One could think having an inner transaction would be easy. My StoreDataBean makes several database calls and all needs to be inside one transaction. If one of they fail they should all be rollbacked and sent to the errorQueue.
onException(Exception.class).handled(true).to(errorQueue); from(inQueue) .transacted() .to("direct:a") ; from("direct:a") .onException(Exception.class).handled(false).markRollbackOnlyLast().end() .transacted("PROPAGATION_REQUIRES_NEW") .bean(new StoreDataBean()) // making several database calls ; But it doesn't work. What I do get working is the following, but I think its the wrong way: from(inQueue) .transacted() .setHeader("storeData", constant(false)) .to("direct:a") .choice().when(header("storeData").isEqualTo(false)) .log("Sending message to errorQueue") .to(errorQueue) ; from("direct:a") .transacted("PROPAGATION_REQUIRES_NEW") .bean(new StoreData()) // making several database calls, setting header to true if all successfull .choice().when(header("storeData").isEqualTo(false)) .log("Stored data to database failed, rollbacking") .markRollbackOnlyLast() .otherwise() .log("Stored data to database successfully") .end() ; Or is there another way? -- View this message in context: http://camel.465427.n5.nabble.com/Proper-way-to-rollback-database-calls-and-send-to-error-queue-tp5768092.html Sent from the Camel - Users mailing list archive at Nabble.com.