0

WebClient我按如下方式创建我的bean:

                WebClient.builder()
                    .clientConnector(
                        ReactorClientHttpConnector(
                            HttpClient.create(
                                ConnectionProvider
                                    .builder("my-client")
                                    .metrics(true)
                                    .maxIdleTime(Duration.ofSeconds(300)).build()
                            )
                                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
                                .doOnConnected { connection: Connection ->
                                    connection.addHandlerLast(ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS))
                                    connection.addHandlerLast(WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS))
                                }
                        )
                    )

它具有指标、超时等,但不使用application.yml.

有没有办法WebClient.Builder预先自动配置并能够在之后设置超时和指标?

4

0 回答 0