Skip to content

Commit

Permalink
Merge pull request #302 from /issues/301-audit-writer-new-transaction
Browse files Browse the repository at this point in the history
Fix #301: Change transaction propagation of DatabaseAuditWriter#flush to REQUIRES_NEW
  • Loading branch information
banterCZ authored Jun 14, 2024
2 parents 1c952d3 + 9f915e6 commit cca6ec0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.StringUtils;

Expand Down Expand Up @@ -159,6 +160,7 @@ public void flush() {
}

synchronized (FLUSH_LOCK) {
transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
transactionTemplate.executeWithoutResult(status -> {
while (!queue.isEmpty()) {
try {
Expand Down
2 changes: 2 additions & 0 deletions audit-base/src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Audit configuration
spring.application.name=test-application

spring.datasource.hikari.auto-commit=false

0 comments on commit cca6ec0

Please sign in to comment.