centiservice / mats3

Mats3: Message-based Asynchronous Transactional Staged Stateless Services
https://mats3.io/
Other
63 stars 7 forks source link

context.doUponFault(Consumer<Exception> after) #17

Open stolsvik opened 5 years ago

stolsvik commented 5 years ago

I recently added a context.doAfterCommit(Runnable), but this is only run if everything goes OK.

It might be nice to be able to have some code run after the lambda, whether or not things went OK. It could accept any outbound Exception. With this, it could be possible to do compensating SQL operations if we ended up in a "VERY BAD!" situation, reducing the problem if it happens? This scenario might even warrant a dedicated method?

An obvious problem here is that this method would be run after each retry. That is, for a default ActiveMQ setting, it would be run 7 times. So the method name context.doFinally(..) is really not appropriate, as that would give the wrong impression.