English 中文(简体)
压缩(Sync)
原标题:Making Blocking (Sync) API call

我的项目是完全同步的网络应用,一米试图利用净服务器节省资源,因为每个申请都使用活动通道。

现在,我的要求是发出一个星号(锁定)外部电话,最后使用24小时的网上电话。 但是,一米差错

block()/blockFirst()/block Last()> 正在阻塞,在校对反应堆-http-nio-6

我的法典


Mono<Map<String,Object>> resMono=wc.post().body(Mono.just(bodyStr), String.class)
  .retrieve().bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {})
  .subscribeOn(Schedulers.boundedElastic())
  .publishOn(Schedulers.boundedElastic())
//.subscribeOn(Schedulers.fromExecutor(webClientExecutor))
  .timeout(Duration.ofSeconds(10)).log("info");


 resMono.share().block();
// resMono.block();

我与To Mono和SubregOn进行了尝试,与Schedulars出版。 但没有任何帮助。

第224(a)号决议使用特定门槛值,随后当同时点击达到5至10点时,要求开始休息(我假定,此时此刻情况已经完整)。

我知道,同一部24小时的网上密码将与Tomcat公司合作,因为它是同一家服务器。 但是,i m试图用网络Client阻止网关申请。

提前感谢。

问题回答

可在@igor Artamonov &的帮助下,从

这里的解决办法是:

1. 建立NioEventLoop 海关检察官小组(没有校对、姓名、封顶盖)

{
    Integer THREADS = 10; 
    Executor EXECUTOR = new ThreadPoolExecutor(THREADS, THREADS, 0L, TimeUnit.MILLISECONDS,
                    new ArrayBlockingQueue<Runnable>(10), new CustomizableThreadFactory("ThreadNamePrefix-"));
  NioEventLoopGroup RESOURCE = new NioEventLoopGroup(THREADS, EXECUTOR);
}

2. 创建特许工厂

public ReactorResourceFactory getReactorResourceFactory() {
        ReactorResourceFactory rf = new ReactorResourceFactory();
        rf.setLoopResources(new LoopResources() {
            @Override
            public EventLoopGroup onServer(boolean b) {
                return RESOURCE;
            }
        });
        rf.setConnectionProvider(ConnectionProvider.create("Custom-WebClient-Name"));
        return rf;
    }

3) 建立ReactorHttpConnector(与SSL环境相结合,允许不安全的地点)

private ClientHttpConnector getCustomReactorHttpConnector() {
    try {
        SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE)
                .build();
        return new ReactorClientHttpConnector(getReactorResourceFactory(),
                httpClient -> httpClient.secure(sslContextSpec -> sslContextSpec.sslContext(sslContext)));
    } catch (Exception e) {

    }
}

4: 建立网络联系(旨在确定最高层的习俗交流战略)

WebClient wc = WebClient.builder().clientConnector(getCustomReactorHttpConnector())
                    .baseUrl(endpoint.getHost() + endpoint.getUrl()).exchangeStrategies(getExchangeStrategies()).build();

5: 呼唤有色体的

Map<String,Object> resMap= wc.post().body(Mono.just(bodyStr), String.class).retrieve().bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {}).share().block();




相关问题
get exchange attributes in @Around aspect java

i implement WebFilter in my project and put an item in exchange.getAttributes() like this: @Override public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { Map<...

Reactive Java: change window size at runtime

I have a Flux emitting items every 1 seconds, on repeat. How can I change the window size dynamically? public static void main(String[] args) throws InterruptedException { Duration interval = ...

How resolve 401 Unauthorized with EnableWebFluxSecurity

My code: @Configuration @EnableWebFluxSecurity @EnableHotmartSecurity @EnableReactiveMethodSecurity(useAuthorizationManager = true) class HttpSecurityConfig { @Bean fun springSecurityFilterChain(...

springboot 3.1.6 webflux trace lost

I constructed the web client using the following method. @Bean public XXXApiService xxxApiClient(HttpClient httpClient, WebClient.Builder builder) { WebClient webClient = builder ...