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"
}
如果有人有解决办法,我会很感激
也许,改变转换器方法(和convertXmlToJson)以采用< code>String而不是< code>Mono
然后你可以这样做:
Mono<String> response = requestString.flatMap(s -> this.convertFormatService.convertXmlToJson(s));
我认为可能还有更多的清理工作可以做,但希望这能让你更接近。
我正在尝试使用WebTest客户端发布数据,但不幸的是,这样的消息被抛出: 为什么会这样?,我不能阻止值,还是邮政编码有问题?我对这种反应式抽象完全陌生,WebTestClient的这种实现使用了非反应式方法。以下是失败的代码: 这里postAndVerify失败: 创建方法的实现如下所示:
我在Spring Webflow中的阻塞操作出错了。我检索地址文档的Mono列表,并使用此地址文档的Mono列表来形成街道地址(带有Street),如下所示: 地图方法: 当我执行上述代码时,它抛出一个“block()/blockFirst()/brockLast()are-blocking,这在线程reactor-http-nio-2中不受支持”。你能建议一下如何修理吗。我想在不阻止它的情况下检
我在Spring Webflow中执行阻塞操作时遇到了一个小问题。我检索文章文档列表,并从文章文档列表中,我想更新另一个对象。 当我执行以下操作时,有时它会工作,有时会抛出“block()/block First()/block Last()被阻塞,这在线程reactor-超文本传输协议-nio-2中是不支持的”。你能建议如何修复吗?我真的不想让它阻塞,但不知道如何继续。stackoverflow
我同意反应性代码不应该阻塞,但是... 在下面的方法findTenantStorageFactory()中,我需要阻止tenantId,这样该方法就可以为租户返回一个特定的工厂。我从Project Reactor中找到了一些说明,说明我需要将方法包装在一个mono.FromCallable()中,并使用boundedElastic()调度程序。但是,当我在调试器中运行此代码时,我会收到可怕的:“b
我用的是IntelliJ IDEA Pro 13.1.2。从未使用过13以下的任何版本。 当试图从IDE运行时,我得到以下消息:
我想在不使用block()/blockFirst()/blockLast()的情况下将mono转换为对象java。请告诉我如何转换它。