经典案例
申博-申博网址登入-申博官方网站下载 常见问题

你的接口,真的能承受高并发吗?

发布于:2019-08-22 20:59来源: 作者:

@Transactional的核心代码如下.这里简单说就是retVal = invocation.proceedWithInvocation方法会去获取数据库连接.

 1if?)?{
2????//?Standard?transaction?demarcation?with?getTransaction?and?commit/rollback?calls.
3????TransactionInfo?txInfo?=?createTransactionIfNecessary;
4????Object?retVal?=?null;
5????try?{
6????????//?This?is?an?around?advice:?Invoke?the?next?interceptor?in?the?chain.
7????????//?This?will?normally?result?in?a?target?object?being?invoked.
8????????retVal?=?invocation.proceedWithInvocation;
9????}
10????catch??{
11????????//?target?invocation?exception
12????????completeTransactionAfterThrowing;
13????????throw?ex;
14????}
15????finally?{
16????????cleanupTransactionInfo;
17????}
18????commitTransactionAfterReturning;
19????return?retVal;
20}




















然后肥朝为了更好的演示这个问题,将数据库连接池的参数做了以下设置

1//初始连接数
2spring.datasource.initialSize=1


tag标签:
------分隔线----------------------------
------分隔线----------------------------