Apr 19th, 2011, 10:27 AM
Poller transactional functionality, checked exceptions and rollback rules
Lets say I have two Pollable[Jms]Channels and a ServiceActivator between them with a transactional poller with atomikos JTA transaction management (xa because of jms+db actions in the same flow). Is there any way to set rollback rules for exceptions raised within this transaction? Is there any way to not rollback on checked exceptions raised by this ServiceActivator?
From both documentation and source code I think that the answer is no. Poller parser uses o.s.t.i.DefaultTransactionAttribute as a default. Making parser read rollback-for and no-rollback-for attributes and build a o.s.t.i.RuleBasedTransactionAttribute is easy but...
...on the other side o.s.i.h.MethodInvokingMessageProcessor and several endpoints wrap the thrown exception into o.s.i.MessagingException (and others from this inheritence tree more specific to the endpoint like o.s.i.MessageTransformationException). So simply by making transaction attribute rule based gives me nothing. MessagingException is-a RuntimeException and the cause is not in the criteria for default rule matching of the spring framework.
What about a customized SIAwaredRuleBasedTransactionAttribute that applies those rules in the first inner cause that is not instanceof MessagingException. It sounds promising for my needs and maybe some similar cases but it may be not that flexible and a lot complex to understand for some more general usage.
What do you think? I am about to give it a try but I'd like to hear your opinion for something like this. Is it the right approach to avoid rollback on some exceptions, if you have something else to suggest you are welcome to enlighten me.
Tags for this Thread