Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arleighdickerson/e702b9d1beeea70607b400878150044e to your computer and use it in GitHub Desktop.
Save arleighdickerson/e702b9d1beeea70607b400878150044e to your computer and use it in GitHub Desktop.
import io.arleigh.gantry.ServicesApplication;
import lombok.RequiredArgsConstructor;
import org.redisson.api.RedissonClient;
import org.redisson.spring.transaction.RedissonTransactionManager;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@RequiredArgsConstructor
@Configuration
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ, proxyTargetClass = ServicesApplication.PROXY_TARGET_CLASS)
class TransactionManagementConfig // implements TransactionManagementConfigurer {
{
private final DataSource dataSource;
private final RedissonClient redisson;
@Bean
@Qualifier("redis")
public RedissonTransactionManager redissonTransactionManager() {
return new RedissonTransactionManager(redisson);
}
@Bean
@Primary
public DataSourceTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment