Hi This requires Camel 2.2 onwards. And check out chapter 9 in the book as it covers using multiple TX demarcations.
On Wed, Apr 21, 2010 at 4:41 PM, ext2 <x...@tongtech.com> wrote: > > Hi: > Camel 's transaction-policy is applied for all processors in the > route; but how to use this features to implement a customized transaction > section in camel? Etc: if I could assign a transaction-policy to a single > pipe-line processor(not the whole route), I could define custom transaction > section easily; > > To illustrate this usage I give a sample , and I want to know is there > a-better solution to use camel; > > For example: A application which read message from jms and, save the message > to 2 different database table(A, B). This application asks for this > transaction features: > > Two database table must keep in a same transaction: one failed another > rollback; > > Jms must take part in seperate transaction, that's to say if both database > success, the jms will commit; if one database failed, I will log the jms > message in a storage, and jms will commit; But if logging failed, the jms > will rollback; > > And how to full-fill this transaction features using camel? > Must I separate the complete route into different route piece just for > transaction support? > Could camel support the define a transaction range (but not a > transaction-policy)? > > Even I separate the complete route into different route just for transaction > support, it still has a difficult: how to declared a new transaction for a > processing route( in this sample , I need to declare a new transaction for > table-A and table-B processors); if I declared a required-new-transaction > policy, all the processor in route act in a separate transaction; and it > cannot full-fill such demand: table A and table B act in a transaction; > To resolve this problem , I must introduce another route just act as a > bridge for the new-tx-range);following is a solution use camel's current > transaction policy to this example, but it's hard to understand: > > routeA: (jms) > (from-jms)-->(required-tx-policy)-->doTry-->(to > direct:new-tx-op)-->(docatch)-->(log); > > routeB:(this is the hardest part for usage) > (from direct:new-tx-op)-->new-tx -policy-->(to direct:db-op) > > Route C: > (from direct:db-op)-->(required-tx-policy)-->(table A save)-->(table B save) > > So does camel support a feature to define transaction range? So the route > will looks like > > (from jms)-->pipeline(required-tx) -->[dotry-->pipeline(new-tx)-->[(table > A)-->(table B)]-->docatch-->log]; > > If camel could assign a transaction-policy to single pipe-line process , > this feature could be achieved easily; > > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus