commit | author | age
|
a18bfa
|
1 |
package com.codingapi.tx.aop.service.impl; |
Z |
2 |
|
|
3 |
import com.codingapi.tx.Constants; |
|
4 |
import com.codingapi.tx.aop.bean.TxTransactionInfo; |
|
5 |
import com.codingapi.tx.aop.bean.TxTransactionLocal; |
|
6 |
import com.codingapi.tx.aop.service.TransactionServer; |
|
7 |
import com.lorne.core.framework.utils.KidUtils; |
|
8 |
import org.aspectj.lang.ProceedingJoinPoint; |
|
9 |
import org.slf4j.Logger; |
|
10 |
import org.slf4j.LoggerFactory; |
|
11 |
import org.springframework.stereotype.Service; |
|
12 |
|
|
13 |
/** |
|
14 |
* 分布式事务启动参与事务中的业务处理(无事务模块) |
|
15 |
* Created by lorne on 2017/6/8. |
|
16 |
*/ |
|
17 |
@Service(value = "txRunningNoTransactionServer") |
|
18 |
public class TxRunningNoTransactionServerImpl implements TransactionServer { |
|
19 |
|
|
20 |
|
|
21 |
private Logger logger = LoggerFactory.getLogger(TxRunningNoTransactionServerImpl.class); |
|
22 |
|
|
23 |
@Override |
|
24 |
public Object execute(final ProceedingJoinPoint point, final TxTransactionInfo info) throws Throwable { |
|
25 |
|
|
26 |
String kid = KidUtils.generateShortUuid(); |
|
27 |
String txGroupId = info.getTxGroupId(); |
|
28 |
logger.debug("--->begin no db transaction, groupId: " + txGroupId); |
|
29 |
long t1 = System.currentTimeMillis(); |
|
30 |
|
|
31 |
|
|
32 |
TxTransactionLocal txTransactionLocal = new TxTransactionLocal(); |
|
33 |
txTransactionLocal.setGroupId(txGroupId); |
|
34 |
txTransactionLocal.setHasStart(false); |
|
35 |
txTransactionLocal.setKid(kid); |
|
36 |
txTransactionLocal.setMaxTimeOut(Constants.txServer.getCompensateMaxWaitTime()); |
|
37 |
TxTransactionLocal.setCurrent(txTransactionLocal); |
|
38 |
|
|
39 |
try { |
|
40 |
return point.proceed(); |
|
41 |
} catch (Throwable e) { |
|
42 |
throw e; |
|
43 |
} finally { |
|
44 |
TxTransactionLocal.setCurrent(null); |
|
45 |
long t2 = System.currentTimeMillis(); |
|
46 |
logger.debug("<---end no db transaction,groupId:" + txGroupId+",execute time:"+(t2-t1)); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
} |