You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Benckhuijsen, JF (Jeroen)" <je...@apg.nl> on 2014/05/25 21:53:11 UTC

Transactions, aggregations, timeouts, file endpoint...

Hi,

I've got the following routes set-up:

Jpa --> aggregation (jdbc, with completion size & timeout) --> multicast to(direct1) & to (direct2)

Direct1 --> bean1 --> marshal(bindy) --> to(file:file1)
Direct2 --> bean2 --> velocity --> to(file: file2)

I.e. I aggregate messages from a JPA store, once enough of them are accumulated or a timeout has been reached, I route the aggregated messages to two endpoints, each of which generates a file. 

I've got a requirement to let this route behave transactional:
* JPA --> aggregation should be transactional: i.e. in case aggregation fails, the item in the JPA store should not be removed
* aggregation --> file1 & file 2 should be transactional: i.e. in case the generation of one of the two files fails, the aggregation should remain and the files should not be written (or deleted via compensations).

I've been fiddling around with transactions and compensations, trying to find answers on the internet and in the Camel inaction book,  but haven't really been able to get the whole thing working. The following questions are what currently bothers me:
* jpa -> aggregation is marked as transacted(). However it seems to me this implies the whole of all routes is transacted (i.e. in case of a failure, the rollback is to the JPA store, not to the aggregation). As the completion timeout may be quite large (e.g. 24 hours), wouldn't this cause a transaction timeout to occur? I've been looking into a second transaction (with REQUIERES_NEW) after the aggregation. Is this the correct way to split the transactions?
* Compensations: although the transaction fails, the onSucces of the Synchronization is called, which to me seems weird.
* In case an error occurs, maintenance personnel would like to receive an email with the error so corrective actions can be taken. I've tried with both the onException() and errorHandler, but both don't seem to do what I want (the message is not delivered, at least, in the case where I used a direct endpoint as a first test case).

Thanks for any help.

Jeroen
De informatie in dit e-mailbericht is vertrouwelijk en uitsluitend bestemd voor de 
geadresseerde. Wanneer u dit bericht per abuis ontvangt, verzoeken wij u contact op te 
nemen met de afzender per kerende e-mail. Verder verzoeken wij u in dat geval dit 
e-mailbericht te vernietigen en de inhoud ervan aan niemand openbaar te maken. 
Wij aanvaarden geen aansprakelijkheid voor onjuiste, onvolledige dan wel ontijdige 
overbrenging van de inhoud van een verzonden e-mailbericht, noch voor daarbij 
overgebrachte virussen.

APG Algemene Pensioen Groep NV is gevestigd te Heerlen en is ingeschreven in het 
handelsregister van de Kamer van Koophandel Limburg onder nummer 14099617


The information contained in this e-mail is confidential and may be privileged. 
It may be read, copied and used only by the intended recipient. 
If you have received it in error, please contact the sender immediately by 
return e-mail; please delete in this case the e-mail and do not disclose its 
contents to any person. We don't accept liability for any errors, omissions, 
delays of receipt or viruses in the contents of this message which arise as a 
result of e-mail transmission.

APG Algemene Pensioen Groep NV is registered in the trade register of the Chamber 
of Commerce Limburg, The Netherlands, registration number: 14099617