java - How to rollback file writes when using Apache Camel transaction? -
i using multicast route in camel 2 pipelines. 1 pipeline adds data database , other write operations on file. requirement rollback complete process in case of failure or error. have rolled db insertions, not able find out way rollback write operations done on file. can me out rollback process. here route context:
<routecontext id="s1route" xmlns="http://camel.apache.org/schema/spring"> <route id="sroute"> <from uri="activemq:queue:{{s.queue}}" /> <log message="message received myprocess queue ${body}"></log> <unmarshal ref="gsonunmarshelling"></unmarshal> <bean beantype="com.***.upload.***.getmybean" method="process(com.**.upload.beans.myevenets,${exchange})" /> <log message="multicasting data ${body} file system , database" /> <multicast parallelprocessing="true"> <pipeline> <choice> <when> <simple>${properties:s.write.file} == true</simple> <setheader headername="path"> <simple>${properties:s.write.folder}</simple> </setheader> <log message="going write file : ${body}"></log> <bean beantype="com.***.upload.processors.tofile" method="process(${exchange},com.***.upload.beans.myfile)" /> <to uri="file://?fileexist=append"></to> </when> </choice> </pipeline> <pipeline> <log message="going insert in database"></log> <transform> <method ref="insertbean" method="mybatchinsertion"></method> </transform> <choice> <when> <simple>${in.header.mycount} == ${properties:batch.size}</simple> <to uri="sql:{{sql.my.insertbatch}}?batch=true"></to> <log message="inserted rows ${body}"></log> </when> </choice> </pipeline> </multicast> </route> </routecontext>
apache commons transaction can deal transactional read , write operations on file system.
you can setup processor com.***.upload.processors.tofile
handle read , write operations transactionally in process()
method.
this apache transaction:write file transactionally - how use resourceid can integrating common transaction in code.
Comments
Post a Comment