由于4.1
版的网关可以返回反应器2.0 Promise<?>
:
@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();
与已更改为反应堆3.1 Mono
5.0
版本开始。
我很确定有一些适配器可以将这些类型转换为RxJava的有价值的东西。
的CompletableFuture<?>
因为4.2
版本也支持网关:
CompletableFuture<String> process(String data);
...
CompletableFuture result = process("foo")
.thenApply(t -> t.toUpperCase());
...
String out = result.get(10, TimeUnit.SECONDS);
http://docs.spring.io/spring-integration/reference/html/messaging-endpoints-chapter.html#async-gateway
感谢@artem。这有助于 – Harry