Pending Transaction - save in external datasource
context init logging added.
This commit is contained in:
parent
f2bf688f85
commit
a7b0fa1c7b
|
@ -38,28 +38,40 @@ public class CommonConfig {
|
||||||
private RedisConnection redisConnection;
|
private RedisConnection redisConnection;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
Repository repository(){
|
Repository repository() {
|
||||||
return new RepositoryImpl(keyValueDataSource(), keyValueDataSource());
|
return new RepositoryImpl(keyValueDataSource(), keyValueDataSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
public KeyValueDataSource keyValueDataSource(){
|
public KeyValueDataSource keyValueDataSource() {
|
||||||
if (CONFIG.getKeyValueDataSource().equals("redis")) {
|
String dataSource = CONFIG.getKeyValueDataSource();
|
||||||
if (redisConnection.isAvailable()) {
|
try {
|
||||||
|
if ("redis".equals(dataSource) && redisConnection.isAvailable()) {
|
||||||
// Name will be defined before initialization
|
// Name will be defined before initialization
|
||||||
return redisConnection.createDataSource("");
|
return redisConnection.createDataSource("");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return new LevelDbDataSource();
|
dataSource = "leveldb";
|
||||||
|
return new LevelDbDataSource();
|
||||||
|
} finally {
|
||||||
|
logger.info(dataSource + " key-value data source created.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Set<Transaction> pendingTransactions() {
|
public Set<Transaction> pendingTransactions() {
|
||||||
return redisConnection.isAvailable()
|
String storage = "Redis";
|
||||||
? redisConnection.createTransactionSet("pendingTransactions")
|
try {
|
||||||
: Collections.synchronizedSet(new HashSet<Transaction>());
|
if (redisConnection.isAvailable()) {
|
||||||
|
return redisConnection.createTransactionSet("pendingTransactions");
|
||||||
|
}
|
||||||
|
|
||||||
|
storage = "In memory";
|
||||||
|
return Collections.synchronizedSet(new HashSet<Transaction>());
|
||||||
|
} finally {
|
||||||
|
logger.info(storage + " 'pendingTransactions' storage created.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
Loading…
Reference in New Issue