0

I need something like the example below with Apache Tomcat.

The main problem here is that we can control database persisting, but in this case we need to send the e-mail if and only if the 'transaction' completed fine.

So, if the database persisting fails, a rollback is done, and if the e-mail is not sent, again a rollback is done. Is it possible?

Begin transaction
    ...
    doing several things...
    ...
    persting information at the database...
    ...
    sending e-mail
    ...
Commit transaction

I would like prefereable a working code or a tutorial showing how can we put it to work on Tomcat. I'm not working with Spring too, so a solution without it would be better.

Thanks in advance.

GarouDan
  • 3,743
  • 9
  • 49
  • 75
  • If this is to function at all you need a two-phase commit, as provided by XA-transactions (part of JavaEE). Not sure whether there is any support for that in tomcat (I think not), and whether there are XA-aware email libraries, but that's the direction you could do some research. – Thomas Stets Mar 05 '15 at 13:21
  • @GarouDan If you don't work with Spring, you can try JPA standalone. http://stackoverflow.com/questions/12688162/java-standalone-app-with-jpa-hibernate-or-similar-and-apache-derby-embedded – zawhtut Mar 05 '15 at 13:46

0 Answers0