Skip to content

Commit

Permalink
Use independent transaction manager
Browse files Browse the repository at this point in the history
  • Loading branch information
jacodg committed Apr 13, 2024
1 parent 71ed496 commit c77515b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import lombok.Getter;
Expand All @@ -66,10 +64,13 @@
// Without proxyTargetClass = true the test webapp will give: Bean named 'proofOfMigrationStorage' is expected to be of
// type 'nl.nn.testtool.storage.proofofmigration.ProofOfMigrationStorage' but was actually of type 'jdk.proxy3.$Proxy26'
@EnableTransactionManagement(proxyTargetClass = true)
// REQUIRES_NEW to prevent interference with transactions of the application that is using Ladybug. Will prevent the
// following error running TestIAF Larva tests with Narayana: You cannot commit during a managed transaction
// READ_UNCOMMITTED to optimize performance and minimize locking
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_UNCOMMITTED)
// Qualifier ladybug makes it possible to have an independent transaction manager to prevent interference with
// transactions of the application that is using Ladybug. It will prevent the following error running TestIAF Larva
// tests with Narayana: You cannot commit during a managed transaction. With propagation = Propagation.REQUIRES_NEW
// this error is also gone but then tests fail with: Commit not allowed by transaction service. To optimize performance
// and minimize locking isolation = Isolation.READ_UNCOMMITTED could be considered but will give the following error for
// Oracle running the TestIAF test matrix: READ_COMMITTED and SERIALIZABLE are the only valid transaction levels.
@Transactional("ladybug")
// @Dependent disabled for Quarkus for now because of the use of JdbcTemplate
public class DatabaseStorage implements LogStorage, CrudStorage {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

<bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
<qualifier value="ladybug"/>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
Expand Down

0 comments on commit c77515b

Please sign in to comment.