/
Problem1Service.java
32 lines (26 loc) · 1014 Bytes
/
Problem1Service.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.github.spring.example.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.support.locks.LockRegistry;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
@Service
public class Problem1Service extends BaseService {
@Autowired
@Qualifier("defaultLockRegistry")
private LockRegistry jdbcLockRegistry;
@Override
protected LockRegistry getLockRegistry() {
return jdbcLockRegistry;
}
@Transactional
public void problem1() {
logCurrentTransaction("start of problem1");
Arrays.asList("a", "b", "c").parallelStream().forEach(key -> {
// https://github.com/spring-projects/spring-integration/issues/3733
logger.info("going to call lock method with key: {}", key);
doWorkInsideLock(key);
});
}
}