Skip to content

Commit e5fb4e3

Browse files
committed
添加打印对tx-group传递参数的日志
1 parent cee7fef commit e5fb4e3

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

transaction-dubbo/src/main/java/com/codingapi/tx/dubbo/filter/TransactionFilter.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@ public class TransactionFilter implements Filter {
1515

1616
@Override
1717
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
18+
1819
TxTransactionLocal txTransactionLocal = TxTransactionLocal.current();
20+
String groupId = txTransactionLocal == null ? null : txTransactionLocal.getGroupId();
21+
int maxTimeOut = txTransactionLocal == null ? 0 : txTransactionLocal.getMaxTimeOut();
1922

23+
logger.info("LCN-dubbo TxGroup info -> groupId:"+groupId+",maxTimeOut:"+maxTimeOut);
2024

2125
if(txTransactionLocal!=null){
22-
String groupId = txTransactionLocal.getGroupId();
23-
int maxTimeOut = txTransactionLocal.getMaxTimeOut();
24-
2526
RpcContext.getContext().setAttachment("tx-group",groupId);
2627
RpcContext.getContext().setAttachment("tx-maxTimeOut",String.valueOf(maxTimeOut));
27-
28-
logger.info("LCN-dubbo TxGroup info -> groupId:"+groupId+",maxTimeOut:"+maxTimeOut);
29-
}else{
30-
logger.info("LCN-dubbo TxGroup info -> groupId:null,maxTimeOut:null");
3128
}
3229

3330
return invoker.invoke(invocation);

transaction-springcloud/src/main/java/com/codingapi/tx/springcloud/http/TransactionHttpRequestInterceptor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ public class TransactionHttpRequestInterceptor implements ClientHttpRequestInter
2222
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
2323

2424
TxTransactionLocal txTransactionLocal = TxTransactionLocal.current();
25-
String groupId = txTransactionLocal==null?null:txTransactionLocal.getGroupId();
25+
String groupId = txTransactionLocal == null ? null : txTransactionLocal.getGroupId();
2626
int maxTimeOut = txTransactionLocal == null ? 0 : txTransactionLocal.getMaxTimeOut();
2727

2828
logger.info("LCN-SpringCloud TxGroup info -> groupId:"+groupId+",maxTimeOut:"+maxTimeOut);
2929

30-
request.getHeaders().add("tx-group",groupId);
31-
request.getHeaders().add("tx-maxTimeOut", String.valueOf(maxTimeOut));
30+
if(txTransactionLocal!=null) {
31+
request.getHeaders().add("tx-group", groupId);
32+
request.getHeaders().add("tx-maxTimeOut", String.valueOf(maxTimeOut));
33+
}
3234
return execution.execute(request,body);
3335
}
3436
}

0 commit comments

Comments
 (0)