github.com/gabrielge/spring-cloud-consumer.git

знаю, симуляция включает функцию ленты, и я доказываю это в своем коде.

Когда я использую feign, правилом по умолчанию является Round Robin Rule. Но как я могу изменить правило в своем симулированном коде клиента, является ли лента единственным способом?

Вот мой код ниже, поэтому, пожалуйста, помогите.

ConsumerApplication.java

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableCircuitBreaker
public class ConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplication.class, args);
    }
}

UserFeignClient .java

@FeignClient(name = "cloud-provider", fallback = UserFeignClient.HystrixClientFallback.class)
public interface UserFeignClient {
    @RequestMapping("/{id}")
    BaseResponse findByIdFeign(@RequestParam("id") Long id);

    @RequestMapping("/add")
    BaseResponse addUserFeign(UserVo userVo);

    @Component
    class HystrixClientFallback implements UserFeignClient {
        private static final Logger LOGGER = LoggerFactory.getLogger(HystrixClientFallback.class);

        @Override
        public BaseResponse findByIdFeign(@RequestParam("id") Long id) {
            BaseResponse response = new BaseResponse();
            response.setMessage("disable");
            return response;
        }

        @Override
        public BaseResponse addUserFeign(UserVo userVo) {
            BaseResponse response = new BaseResponse();
            response.setMessage("disable");
            return response;
        }
    }
}

FeignController.java

@RestController
public class FeignController {

    @Autowired
    private UserFeignClient userFeignClient;

    @GetMapping("feign/{id}")
    public BaseResponse<Date> findByIdFeign(@PathVariable Long id) {
        BaseResponse response = this.userFeignClient.findByIdFeign(id);
        return response;
    }

    @GetMapping("feign/user/add")
    public BaseResponse<Date> addUser() {
        UserVo userVo = new UserVo();
        userVo.setAge(19);
        userVo.setId(12345L);
        userVo.setUsername("nick name");
        BaseResponse response = this.userFeignClient.addUserFeign(userVo);
        return response;
    }
}

Ответы на вопрос(1)

Ваш ответ на вопрос