You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Frank Ertl <fr...@f-i-solutions-plus.de> on 2015/04/15 20:36:13 UTC

JPA-Endpoint in onException is not committed

Hi folks,

I have the following RouteBuilder:

   onException(Throwable.class)
        .handled(true)
        .bean(orderStateChanger, "changeOrderStateToWaiting")
        .to("jpa:Order");


    from("jms:order_queue")
        .routeId("Order_Route")
        .transacted()
        .setHeader(ORDER_ID_HEADER, simple("${body}"))
        .bean(orderByIdReader)
        .process(orderMapper)
        .to("cxf:bean:orderWebService")
        .process(postOrderProcessor);

The route reads an orderId from a jms-queue, sets this id to a header for
later use and enriches the message with the order read from the database.
Then the order ist mapped and send to a webservice. After returning some
postprocessing is done. All unittest using CamelSpringTestSupport work well.
So far so good.
Now integrating the solution in the real world shows some strange behaviour:
If an exception is thrown by the webservice the onException kicks in and the
StateChangerBean is called.
BUT: the change seems never to be committed. I thought that using the
jpa-component inside a springcontext would manage to handle all the tx-magic
but obviously that's not the case. Instead I see the following output in the
log:

TransactionErrorHandler - Transaction commit (0x550d4ee1) redelivered(true)
for (MessageId: ID:1D4923BFB6FF48CF997D5353C351D271 

I studied the documentation, but perhaps I searched in the wrong places? As
we say in german: Can anybody help me climb the correct camel, please? 


Regards,
Frank





--
View this message in context: http://camel.465427.n5.nabble.com/JPA-Endpoint-in-onException-is-not-committed-tp5765832.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JPA-Endpoint in onException is not committed

Posted by Frank Ertl <fr...@f-i-solutions-plus.de>.
OK, I found it out myself: somehow the TransactionErrorHandler and Spring's
PlatformTransactionManager don't work so well together.
If I remove the  .to("jpa:Order"); in the onException everything works well.

So I got another question: Should I update the wiki.description for the
jpacomponent and the section "Transactional" in error handling? 



--
View this message in context: http://camel.465427.n5.nabble.com/JPA-Endpoint-in-onException-is-not-committed-tp5765832p5765852.html
Sent from the Camel - Users mailing list archive at Nabble.com.