-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: fix Alibaba Dubbo convert error (#6675)
- Loading branch information
Showing
4 changed files
with
86 additions
and
33 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...ava/org/apache/seata/integration/dubbo/alibaba/AlibabaDubboTransactionConsumerFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.seata.integration.dubbo.alibaba; | ||
|
||
import com.alibaba.dubbo.common.extension.Activate; | ||
import com.alibaba.dubbo.rpc.Filter; | ||
import com.alibaba.dubbo.rpc.Invocation; | ||
import com.alibaba.dubbo.rpc.Invoker; | ||
import com.alibaba.dubbo.rpc.Result; | ||
import com.alibaba.dubbo.rpc.RpcContext; | ||
import com.alibaba.dubbo.rpc.RpcException; | ||
|
||
import org.apache.seata.core.constants.DubboConstants; | ||
import org.apache.seata.core.context.RootContext; | ||
import org.apache.seata.core.model.BranchType; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* The type Alibaba dubbo transaction consumer filter. | ||
*/ | ||
@Activate(group = {DubboConstants.CONSUMER}, order = 100) | ||
public class AlibabaDubboTransactionConsumerFilter implements Filter { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(AlibabaDubboTransactionConsumerFilter.class); | ||
|
||
@Override | ||
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { | ||
if (!DubboConstants.ALIBABADUBBO) { | ||
return invoker.invoke(invocation); | ||
} | ||
String xid = RootContext.getXID(); | ||
BranchType branchType = RootContext.getBranchType(); | ||
|
||
if (LOGGER.isDebugEnabled()) { | ||
LOGGER.debug("consumer xid in RootContext[{}], branchType in RootContext[{}]", xid, branchType); | ||
} | ||
if (xid != null) { | ||
RpcContext.getContext().setAttachment(RootContext.KEY_XID, xid); | ||
RpcContext.getContext().setAttachment(RootContext.KEY_BRANCH_TYPE, branchType.name()); | ||
} | ||
try { | ||
return invoker.invoke(invocation); | ||
} finally { | ||
RpcContext.getContext().removeAttachment(RootContext.KEY_XID); | ||
RpcContext.getContext().removeAttachment(RootContext.KEY_BRANCH_TYPE); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
integration/dubbo-alibaba/src/main/resources/META-INF/services/com.alibaba.dubbo.rpc.Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
org.apache.seata.integration.dubbo.alibaba.AlibabaDubboTransactionPropagationFilter | ||
org.apache.seata.integration.dubbo.alibaba.AlibabaDubboTransactionConsumerFilter | ||
org.apache.seata.integration.dubbo.alibaba.AlibabaDubboTransactionProviderFilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters