- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想制作一个示例原型(prototype),其中使用 Spring Reactor Stream API 由 ServiceA 返回的值来调用 ServiceC。所以我写了这样的代码
final ExecutorService executor = new ThreadPoolExecutor(4, 4, 10, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
Streams.defer(executor.submit(new CallToRemoteServiceA()))
.flatMap(s -> Streams.defer(executor.submit(new CallToRemoteServiceC(s))))
.consume(s -> System.out.println("End Result : " + s));
为了模拟 ServiceA 和 ServiceC 中涉及的延迟,CallToRemoteServiceA 和 CallToRemoteServiceC 的 call() 方法具有 Thread.sleep() 方法。问题是,当我注释掉 Thread.sleep() 方法时,即服务方法调用没有延迟,这在现实世界中是不正确的,消耗方法被调用。如果 Thread.sleep() 方法保留在适当的位置,则不会调用 Consumer 方法。我知道 Streams.defer() 返回一个冷流,因此它可能只对注册后接受的项目执行消费方法,但后来我想知道如何从 ExecutorService 返回的 Future 创建 HotStream?
最佳答案
我相信这是由于reactor.rx.stream.FutureStream.subscribe()方法中的错误造成的。在这一行中:
try {
// Bug in the line below since unit is never null
T result = unit == null ? future.get() : future.get(time, unit);
buffer.complete();
onNext(result);
onComplete();
} catch (Throwable e) {
onError(e); <-- With default constructor this gets called if time == 0 and
future has as yet not returned
}
在这种情况下,当调用默认的 FutureStream(Future) 构造函数时,单位永远不会为 null,因此上面的代码总是调用 future.get(0, TimeUnit.SECONDS) ,导致 catch(Throwable) 中立即出现超时异常堵塞。如果你们同意这是一个错误,我可以提出拉取请求并修复此问题?
关于java - 通过 Spring Reactor 从 Future 创建 HotStream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27513037/
我正在尝试找出我们应该在下一个项目中使用 Akka 还是 Reactor。最重要的问题之一是 future 选择的框架是否会提供远程处理。正如我所看到的,Akka 以我们想要的方式提供了这个。 在 G
假设我有一个返回 Mono 的 repository.save(..) 方法。 还可以说我有一个 repository.findByEmail(..) 它返回一个 Mono。 问题: 我希望第一个 M
有一个像下面这样的异步发布者,Project Reactor 有没有办法等到整个流完成处理? 当然,不必添加一个未知持续时间的 sleep ...... @Test public void group
我创建了一个简单的 Kafka 消费者,它返回 Flux对象(收到的消息),我正在尝试使用 StepVerifier 对其进行测试. 在我的测试中,我做了这样的事情: Flux flux = cons
我目前正在研究resilience4j 库,由于某种原因,以下代码无法按预期工作: @Test public void testRateLimiterProjectReactor() { //
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 7 年前。 Improv
当多个 onErrorContinue添加到管道 处理从 flatMap 抛出的特定类型的异常 ,异常处理没有按预期工作。 我希望下面的代码应该删除元素 1 到 6,而订阅者应该使用元素 7 到 10
我有一个 NettyServerCustomizer,下一个代码: @Override public HttpServer apply(final HttpServer httpServer)
我们正在评估 reactor 库以便在我们的项目中使用它。我们的项目得到了 spring 上下文的支持。因此,我们需要一个工具来构建具有 spring 支持的事件驱动应用程序。 此外,我们的主要关注领
不管上游的完整性如何,有没有办法强制 groupBy() 生成的 Flux 在一段时间后完成(或类似地,限制“打开”组的最大数量)?我有如下内容: Flux someFastPublisher; so
我正在使用 Spring WebClient 调用休息服务。如下所述的 post 调用代码。 Mono response = client.post()
我希望在 react 器运行后添加更多协议(protocol)和工厂。我找不到说明这是允许的文档。当我在 reactor.connectTCP 之前运行 reactor.run 时,程序会在工厂中围绕
(译者加)本文档的一些典型的名词如下: Publisher(发布者)、Subscriber(订阅者)、Subscription(订阅 n.)、subscribe(订阅 v.)。 event/signa
Project Reactor Mono 是否有运算符或一些好的方法来实现 doOnEmpty() 的行为? 我想对操作结果产生副作用(日志记录)。 这是我现在拥有的: myMono .map(v
在以下两个示例中,处理通量流的行为似乎有所不同。 示例 1: public static void main(String[] args) throws InterruptedException {
是否可以使用 LoggingMeterRegistry 以微米为单位收集项目 react 器的通量指标? 最佳答案 只需添加 LoggingMeterRegistry 就可以了到全局 Micromet
我想知道在spring web-flux中使用先前映射结果的好方法,例如 Mono.just(request) ... .flatMap(object0 -> createObject1(object
如何将具有1个元素的助焊剂转换为单声道? Flux.fromArray(arrayOf(1,2,1,1,1,2)) .distinct()
我想知道Reactor和分页的HTTP API。我有一个private fun getPage(pageNumber: Int): Mono。该资源具有“numberOfPages”字段,我想获取所有
我有一个包含多个 URL 和端口的数组。对于他们每个人,我需要发送和接收返回的内容: Flux.fromArray(trackersArray) .flatMap(tracker ->
我是一名优秀的程序员,十分优秀!