Spring integration Spring中的异步消息网关与RxNetty集成
我正在尝试将Spring集成中的异步消息传递网关与RxNetty(异步HTTP)结合起来。基本上,我想要的是将一个可观察/可完成的未来返回给调用线程,并使用可观察的zip/map/flatmap在调用线程中进行大量出站HTTP调用。我只是想看看这是否有可能。另外,如果不使用Rxjava构造,我最好使用聚合器eip来构建一个简单的工作流。由于版本Spring integration Spring中的异步消息网关与RxNetty集成,spring-integration,rx-netty,Spring Integration,Rx Netty,我正在尝试将Spring集成中的异步消息传递网关与RxNetty(异步HTTP)结合起来。基本上,我想要的是将一个可观察/可完成的未来返回给调用线程,并使用可观察的zip/map/flatmap在调用线程中进行大量出站HTTP调用。我只是想看看这是否有可能。另外,如果不使用Rxjava构造,我最好使用聚合器eip来构建一个简单的工作流。由于版本4.1网关可以返回Reactor 2.0Promise: @MessagingGateway public static interface TestG
4.1
网关可以返回Reactor 2.0Promise
:
@MessagingGateway
public static interface TestGateway {
@Gateway(requestChannel = "promiseChannel")
Promise<Integer> multiply(Integer value);
}
...
@ServiceActivator(inputChannel = "promiseChannel")
public Integer multiply(Integer value) {
return value * 2;
}
...
Streams.defer(Arrays.asList("1", "2", "3", "4", "5"))
.get()
.map(Integer::parseInt)
.mapMany(integer -> testGateway.multiply(integer))
.collect()
.consume(integers -> ...)
.flush();
CompletableFuture<String> process(String data);
...
CompletableFuture result = process("foo")
.thenApply(t -> t.toUpperCase());
...
String out = result.get(10, TimeUnit.SECONDS);