当前位置: 首页 > 知识库问答 >
问题:

块()/块第一()/块最后() 是阻塞,这在线程反应器-http-nio-3 中不受支持

唐康安
2023-03-14

I使用SpringSpring靴2.1.0。

public Mono<ServerResponse> getConvertXmlToJson(ServerRequest serverRequest) {
        Mono<String> requestString = serverRequest.bodyToMono(String.class);
        Mono<String> response = this.convertFormatService.convertXmlToJson(requestString);
        return response.subscribeOn(elastic()).flatMap(rta -> ok()
                .contentType(APPLICATION_JSON_UTF8)
                .body(fromObject(rta)))
                .switchIfEmpty(ServerResponse.badRequest().build());
    }

在其他bean中调用此方法

private Mono<String> converter(String function, Mono<String> stringToConverter, String setting) {
    log.info("salida, {}", stringToConverter.block());
    try {
        Object result = invocable.invokeFunction(function, stringToConverter, setting);
        log.info("{}", result);
        return Mono.just((String) result);
    } catch (Exception e) {
        throw new ConverterException(e.getMessage());
    }
}

我需要传递一个字符串值,而不是Mono,当我传递Mono时,答案是空的。

当我试图从Mono获取字符串值时,我得到了一个错误:

{
    "timestamp": "2018-11-13T03:29:02.161+0000",
    "path": "/v1/convert",
    "status": 500,
    "error": "Internal Server Error",
    "message": "block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3",
    "trace": "java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3\r\n\tat reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:77)\r\n\tat reactor.core.publisher.Mono.block(Mono.java:1475)\r\n\tat lf.co.com.examplespringconverterxmljson.services.impl.ConvertFormatServiceImpl.converter(ConvertFormatServiceImpl.java:58)\r\n\tat lf.co.com.examplespringconverterxmljson.services.impl.ConvertFormatServiceImpl.convertXmlToJson(ConvertFormatServiceImpl.java:49)\r\n\tat lf.co.com.examplespringconverterxmljson.routing.handler.ConvertHandler.getConvertXmlToJson(ConvertHandler.java:25)\r\n\tat org.springframework.web.reactive.function.server.support.HandlerFunctionAdapter.handle(HandlerFunctionAdapter.java:61)\r\n\tat org.springframework.web.reactive.DispatcherHandler.invokeHandler(DispatcherHandler.java:159)\r\n\tat org.springframework.web.reactive.DispatcherHandler.lambda$handle$1(DispatcherHandler.java:151)\r\n\tat reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:118)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:76)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:275)\r\n\tat reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:849)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:114)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2041)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.request(FluxOnAssembly.java:458)\r\n\tat reactor.core.publisher.FluxMap$MapSubscriber.request(FluxMap.java:155)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.request(FluxOnAssembly.java:458)\r\n\tat reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1849)\r\n\tat reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1723)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onSubscribe(FluxOnAssembly.java:442)\r\n\tat reactor.core.publisher.FluxMap$MapSubscriber.onSubscribe(FluxMap.java:86)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onSubscribe(FluxOnAssembly.java:442)\r\n\tat reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)\r\n\tat reactor.core.publisher.MonoCallableOnAssembly.subscribe(MonoCallableOnAssembly.java:82)\r\n\tat reactor.core.publisher.MonoMap.subscribe(MonoMap.java:55)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:74)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.Mono.subscribe(Mono.java:3590)\r\n\tat reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:442)\r\n\tat reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onSubscribe(FluxConcatMap.java:212)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onSubscribe(FluxOnAssembly.java:442)\r\n\tat reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:139)\r\n\tat reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:63)\r\n\tat reactor.core.publisher.FluxOnAssembly.subscribe(FluxOnAssembly.java:164)\r\n\tat reactor.core.publisher.FluxConcatMap.subscribe(FluxConcatMap.java:121)\r\n\tat reactor.core.publisher.FluxOnAssembly.subscribe(FluxOnAssembly.java:164)\r\n\tat reactor.core.publisher.MonoNext.subscribe(MonoNext.java:40)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoSwitchIfEmpty.subscribe(MonoSwitchIfEmpty.java:44)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1476)\r\n\tat reactor.core.publisher.MonoProcessor.onNext(MonoProcessor.java:389)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:373)\r\n\tat reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2041)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.request(FluxOnAssembly.java:458)\r\n\tat reactor.core.publisher.MonoProcessor.onSubscribe(MonoProcessor.java:399)\r\n\tat reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onSubscribe(FluxOnAssembly.java:442)\r\n\tat reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)\r\n\tat reactor.core.publisher.MonoCallableOnAssembly.subscribe(MonoCallableOnAssembly.java:82)\r\n\tat reactor.core.publisher.Mono.subscribe(Mono.java:3590)\r\n\tat reactor.core.publisher.MonoProcessor.add(MonoProcessor.java:531)\r\n\tat reactor.core.publisher.MonoProcessor.subscribe(MonoProcessor.java:444)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:71)\r\n\tat reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.core.publisher.Mono.subscribe(Mono.java:3590)\r\n\tat reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)\r\n\tat reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:71)\r\n\tat reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:70)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:71)\r\n\tat reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)\r\n\tat reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76)\r\n\tat reactor.netty.http.server.HttpServerHandle.onStateChange(HttpServerHandle.java:64)\r\n\tat reactor.netty.tcp.TcpServerBind$ChildObserver.onStateChange(TcpServerBind.java:226)\r\n\tat reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:431)\r\n\tat reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:141)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)\r\n\tat reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:159)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)\r\n\tat io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)\r\n\tat io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)\r\n\tat io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)\r\n\tat io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)\r\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)\r\n\tat io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)\r\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\r\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\r\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)\r\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)\r\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628)\r\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)\r\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)\r\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)\r\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\n\tSuppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: \nAssembly trace from producer [reactor.core.publisher.MonoFlatMap] :\n\treactor.core.publisher.Mono.flatMap(Mono.java:2454)\n\torg.springframework.web.reactive.DispatcherHandler.handle(DispatcherHandler.java:151)\n\torg.springframework.web.server.handler.DefaultWebFilterChain.lambda$filter$0(DefaultWebFilterChain.java:122)\n\treactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:44)\n\treactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)\n\treactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)\n\treactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1476)\n\treactor.core.publisher.MonoProcessor.onNext(MonoProcessor.java:389)\n\treactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2041)\n\treactor.core.publisher.MonoProcessor.onSubscribe(MonoProcessor.java:399)\n\treactor.core.publisher.MonoJust.subscribe(MonoJust.java:54)\n\treactor.core.publisher.Mono.subscribe(Mono.java:3590)\n\treactor.core.publisher.MonoProcessor.add(MonoProcessor.java:531)\n\treactor.core.publisher.MonoProcessor.subscribe(MonoProcessor.java:444)\n\treactor.core.publisher.MonoMapFuseable.subscribe(MonoMapFuseable.java:59)\n\treactor.core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)\n\treactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)\n\treactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)\n\treactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)\n\treactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)\n\treactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)\n\treactor.core.publisher.Mono.subscribe(Mono.java:3590)\n\treactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:172)\n\treactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56)\n\treactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:70)\n\treactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61)\n\treactor.netty.http.server.HttpServerHandle.onStateChange(HttpServerHandle.java:64)\n\treactor.netty.tcp.TcpServerBind$ChildObserver.onStateChange(TcpServerBind.java:226)\n\treactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:431)\n\treactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:141)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\n\tio.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)\n\treactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:159)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\n\tio.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)\n\tio.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438)\n\tio.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)\n\tio.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)\n\tio.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)\n\tio.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)\n\tio.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\n\tio.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)\n\tio.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\n\tio.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)\n\tio.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)\n\tio.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628)\n\tio.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)\n\tio.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)\n\tio.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)\n\tio.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)\nError has been observed by the following operator(s):\n\t|_\tMono.flatMap ⇢ org.springframework.web.reactive.DispatcherHandler.handle(DispatcherHandler.java:151)\n\t|_\tMono.flatMap ⇢ org.springframework.web.reactive.DispatcherHandler.handle(DispatcherHandler.java:152)\n\t|_\tMono.defer ⇢ org.springframework.web.server.handler.DefaultWebFilterChain.filter(DefaultWebFilterChain.java:119)\n\t|_\tMono.flatMap ⇢ org.springframework.web.filter.reactive.HiddenHttpMethodFilter.filter(HiddenHttpMethodFilter.java:90)\n\t|_\tMono.defer ⇢ org.springframework.web.server.handler.DefaultWebFilterChain.filter(DefaultWebFilterChain.java:119)\n\r\n"
}

如果有人有解决办法,我会很感激

共有1个答案

澹台宾白
2023-03-14

也许,改变转换器方法(和convertXmlToJson)以采用< code>String而不是< code>Mono

然后你可以这样做:

Mono<String> response = requestString.flatMap(s -> this.convertFormatService.convertXmlToJson(s));

我认为可能还有更多的清理工作可以做,但希望这能让你更接近。

 类似资料: