刘光辉
昨天 bb638871a7fb692d80f1b7a758f991dc0879002c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package jnpf.audit.fallback;
 
import jnpf.audit.AuditDeliveryException;
import jnpf.audit.AuditEventApi;
import jnpf.audit.model.AuditEventDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
 
@Component
@Slf4j
public class AuditEventApiFallbackFactory implements FallbackFactory<AuditEventApi> {
    @Override
    public AuditEventApi create(Throwable cause) {
        return dto -> {
            // 关键:把异常重新抛出,让 SDK 降级链感知失败(L009 教训:静态 fallback 静默吞会误判成功)
            throw new AuditDeliveryException("Feign 投递审计事件失败", cause);
        };
    }
}