Skip to content

Instantly share code, notes, and snippets.

@iundarigun
Last active November 13, 2020 21:27
Show Gist options
  • Select an option

  • Save iundarigun/eba3bbfc10506894da5667e377023f78 to your computer and use it in GitHub Desktop.

Select an option

Save iundarigun/eba3bbfc10506894da5667e377023f78 to your computer and use it in GitHub Desktop.
SampleTransactionRouting
@Configuration
class TransactionRoutingConfiguration {
@Bean
@Primary
fun dataSource(): DataSource {
val transactionRoutingDataSource = TenantDataSource()
val datasource1 = buildDataSourceFromProperties("datasource1")
val datasource2 = buildDataSourceFromProperties("datasource2")
val targetDataSources: MutableMap<Any, Any> = mutableMapOf(
"client1" to datasource1,
"client2" to datasource2
)
transactionRoutingDataSource.setDefaultTargetDataSource(datasource1)
transactionRoutingDataSource.setTargetDataSources(targetDataSources)
transactionRoutingDataSource.afterPropertiesSet()
return transactionRoutingDataSource
}
// More methods
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment