刘光辉
15 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
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);
        };
    }
}