Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Starting a different transaction in the method through Spring

Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have this scenario where i need to audit certain operations and insert rows in some audit table.
So i have taken this approach, whenever the method A in class A is called which does that operation, i call my auditService's method B to insert the record in the audit table. Now, i have marked the propagation on method B as REQUIRES_NEW so that always a new transaction is created whenever the audit record is created.

I am able to successfully make it work but i was thinking is it possible to start the second transaction in a second thread so that the initial thread is not delayed in any way.
I could use the java.util.Timer API for it, but somehow something doesn't look right.

Any thoughts/suggestions please.

Thank you

There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic