Skip to content

Commit 1905870

Browse files
authored
Merge pull request #557 from boylong12/dev6.0
dubbo rpc 拦截器
2 parents d86dc1f + 311e1ec commit 1905870

File tree

5 files changed

+44
-4
lines changed

5 files changed

+44
-4
lines changed

txlcn-tc/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
<scope>provided</scope>
3434
</dependency>
3535

36+
<dependency>
37+
<groupId>com.alibaba</groupId>
38+
<artifactId>dubbo</artifactId>
39+
<scope>provided</scope>
40+
</dependency>
41+
3642
<dependency>
3743
<groupId>com.codingapi.txlcn</groupId>
3844
<artifactId>txlcn-p6spy</artifactId>
@@ -82,7 +88,6 @@
8288
<artifactId>mysql-connector-java</artifactId>
8389
<scope>test</scope>
8490
</dependency>
85-
8691
</dependencies>
8792

8893

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.codingapi.txlcn.tc.rpc;
2+
3+
import com.alibaba.dubbo.common.Constants;
4+
import com.alibaba.dubbo.common.extension.Activate;
5+
import com.alibaba.dubbo.rpc.*;
6+
7+
/**
8+
* @author zhanghonglong
9+
* @date 2020/10/28 11:01
10+
*/
11+
@Activate(group = Constants.CONSUMER)
12+
public class DubboConsumerRpcTransactionInterceptor implements Filter {
13+
@Override
14+
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
15+
RpcTransactionContext.getInstance().build(invocation.getAttachments()::put);
16+
return invoker.invoke(invocation);
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.codingapi.txlcn.tc.rpc;
2+
3+
import com.alibaba.dubbo.common.Constants;
4+
import com.alibaba.dubbo.common.extension.Activate;
5+
import com.alibaba.dubbo.rpc.*;
6+
7+
/**
8+
* @author zhanghonglong
9+
* @date 2020/10/28 11:01
10+
*/
11+
@Activate(group = Constants.PROVIDER)
12+
public class DubboProviderRpcTransactionInterceptor implements Filter {
13+
@Override
14+
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
15+
RpcTransactionContext.getInstance().invoke(invocation.getAttachments()::get);
16+
return invoker.invoke(invocation);
17+
}
18+
}

txlcn-tc/src/main/java/com/codingapi/txlcn/tc/rpc/RpcTransactionConfiguration.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,4 @@ public RpcTransactionHandlerInterceptor rpcTransactionHandlerInterceptor(){
4949
}
5050

5151
}
52-
53-
54-
5552
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DubboConsumerTransactionFilter=com.codingapi.txlcn.tc.rpc.DubboConsumerRpcTransactionInterceptor
2+
DubboProviderTransactionFilter=com.codingapi.txlcn.tc.rpc.DubboProviderRpcTransactionInterceptor

0 commit comments

Comments
 (0)