how to configuration spring aop with TraceLoadBalancerFeignClient ?
i using spring-cloud-sleuth in project,
i want to do some thing after TraceLoadBalancerFeignClient.execute finish.
so,i try configuration spring aspect,like that
@Around("execution (* org.springframework.cloud.sleuth.instrument.web.client.feign.TraceLoadBalancerFeignClient.execute(..))")
public Object feignClientWasCalled(final ProceedingJoinPoint pjp) throws Throwable {
Object[] args = pjp.getArgs();
Request request = (Request) args[0];
Request.Options options = (Request.Options) args[1];
Object bean = pjp.getTarget();
Object resp = pjp.proceed();
//do some thing
return resp;
but not work.
if i want to do something after TraceLoadBalancerFeignClient.execute,what shoud i do?
What do you want to do exactly?
@marcingrzejszczak exactly, i hope when my feignClient Load balancer does not have available server for client ,try request to remote proxy url,so i want to add custom bussiness.
TraceLoadBalancerFeignClient is an implementation detail. You shouldn't be touching that.
TLBFC is calling a delegate, so whichever LoadBalancerFeignClient delegate you had, it will get called by the TLBFC. You should define your logic in your implementation of a LoadBalancerFeignClient.
i try define myLoadBalancerFeignClient extend of LoadBalancerFeignClient , and override the LBFC.execute,
but not work;
i debug the code,
TraceFeignObjectWrapper.warp alway warp Client, if the Client instanceof LoadBalancerFeignClient,it will use client.getDelegate() to rebuild TraceLoadBalancerFeignClient,and myLoadBalancerFeignClient is useless and not work.
the code of TraceFeignObjectWrapper
Object wrap(Object bean) {
if (bean instanceof Client && !(bean instanceof TraceFeignClient)) {
if (bean instanceof LoadBalancerFeignClient && !(bean instanceof TraceLoadBalancerFeignClient)) {
LoadBalancerFeignClient client = ((LoadBalancerFeignClient) bean);
return new TraceLoadBalancerFeignClient(
client.getDelegate(), factory(),
clientFactory(), this.beanFactory);
} else if (bean instanceof TraceLoadBalancerFeignClient) {
return bean;
}
return new TraceFeignClient(this.beanFactory, (Client) bean);
}
return bean;
}
How can i have any way to use custom LoadBalancerFeignClient? @marcingrzejszczak