Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize: alibaba-seata: Transfer XID using feign.RequestInterceptor #1946

Merged
merged 12 commits into from
Dec 21, 2022

Conversation

wangliang181230
Copy link
Contributor

@wangliang181230 wangliang181230 commented Jan 26, 2021

Describe what this PR does / why we need it

optimize: alibaba-seata: Transfer XID using feign.RequestInterceptor

解决的问题:

  1. 避免alibaba-seata与zipkin冲突,导致服务发现功能异常。
  2. 避免alibaba-seata与zipkin重复定义了 bean Feign.Builder feignHystrixBuilder(BeanFactory beanFactory);

Does this pull request fix one issue?

Fixes #1307
Fixes #1377

Describe how you did it

NONE

Describe how to verify it

NONE

Special notes for reviews

NONE

…seata-transmit-xid

# Conflicts:
#	spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/feign/SeataFeignObjectWrapper.java
@jasondeng1997
Copy link

jasondeng1997 commented Oct 14, 2022

为什么把seata的feign全部删掉,冲突的话指出具体冲突在哪里,解决冲突,这个删除的太多,具体单侧通过了吗

@wangliang181230
Copy link
Contributor Author

wangliang181230 commented Oct 26, 2022

为什么把seata的feign全部删掉,冲突的话指出具体冲突在哪里,解决冲突,这个删除的太多,具体单侧通过了吗

@jasondeng1997

这些类的目的就两个:

  1. 设置feign的重试策略为不重试(NEVER_RETRY),避免一个请求被分割成两个线程导致一致性问题的产生。
  2. 传递XID。

原来的代码存在的问题:

  1. 是直接自己创建一个bean,但这样会影响通过配置调整builder的其他属性。所以我采用了BeanPostProcessor来捕获Builder的bean并更换它的重试策略为NEVER_RETRY.
  2. 采用了代理的方式,但是feign已经提供的拦截器功能,用于注入请求头,拦截器的实现更加简洁,逻辑更加直观。不像代理那样,要代理掉各种内容。

两个类就能实现的功能,为什么要用10个类呢?是吧。

@yuhuangbin yuhuangbin merged commit 3cb9c96 into alibaba:2.2.x Dec 21, 2022
@wangliang181230 wangliang181230 deleted the optimize-seata-transmit-xid branch December 21, 2022 02:47
wangliang181230 added a commit to wangliang181230/spring-cloud-alibaba that referenced this pull request Dec 21, 2022
alibaba#1946)

* optimize: alibaba-seata: Transfer XID using `feign.RequestInterceptor`

* 移除多余的代码

* imports顺序调整。

* Feign.Builder的默认retryer修改为NEVER_RETRY。

* fix style

* fix style

* Update SeataFeignBuilderBeanPostProcessor.java

* add static
yuhuangbin pushed a commit that referenced this pull request Dec 21, 2022
#1946) (#2993)

* optimize: alibaba-seata: Transfer XID using `feign.RequestInterceptor`

* 移除多余的代码

* imports顺序调整。

* Feign.Builder的默认retryer修改为NEVER_RETRY。

* fix style

* fix style

* Update SeataFeignBuilderBeanPostProcessor.java

* add static
wangliang181230 added a commit to wangliang181230/spring-cloud-alibaba that referenced this pull request Feb 23, 2023
alibaba#1946) (alibaba#2993)

* optimize: alibaba-seata: Transfer XID using `feign.RequestInterceptor`

* 移除多余的代码

* imports顺序调整。

* Feign.Builder的默认retryer修改为NEVER_RETRY。

* fix style

* fix style

* Update SeataFeignBuilderBeanPostProcessor.java

* add static
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants