Java:从 Play Framework 应用程序使用 Spring WebFlux 应用程序
Java: consuming a Spring WebFlux application from a Play Framework application
我有一些关于通过 HTTP 从 Play Framework 应用程序使用 Spring WebFlux 应用程序的问题,你能提供一些帮助吗?
微服务A是一个响应式的SpringWebFlux,写在Java8,SpringBoot 2.1.4,暴露这个API:
@Autowired private ReactiveCustomerRepository customerRepository;
@GetMapping("/customers")
public Flux<Customer> getAllCustomers() {
Flux<Customer> c = customerRepository.findAll().delayElements(Duration.ofMillis(5000));
return c;
}
我想通过 HTTP 从 Play Framework 微服务 B 以反应方式使用它。
能否就如何实现这一目标提供一些建议或一小段代码?
感谢您的帮助。
您可以尝试使用支持流式传输的不同 content-type - application/stream+json
。 Spring WebFlux 将序列化各个 Flux 元素并通过网络将它们一一发送。查看以下有关它的 SO 线程:
在 play-ws 端,您应该能够接收此数据作为 Source[T]
。
我有一些关于通过 HTTP 从 Play Framework 应用程序使用 Spring WebFlux 应用程序的问题,你能提供一些帮助吗?
微服务A是一个响应式的SpringWebFlux,写在Java8,SpringBoot 2.1.4,暴露这个API:
@Autowired private ReactiveCustomerRepository customerRepository;
@GetMapping("/customers")
public Flux<Customer> getAllCustomers() {
Flux<Customer> c = customerRepository.findAll().delayElements(Duration.ofMillis(5000));
return c;
}
我想通过 HTTP 从 Play Framework 微服务 B 以反应方式使用它。
能否就如何实现这一目标提供一些建议或一小段代码?
感谢您的帮助。
您可以尝试使用支持流式传输的不同 content-type - application/stream+json
。 Spring WebFlux 将序列化各个 Flux 元素并通过网络将它们一一发送。查看以下有关它的 SO 线程:
在 play-ws 端,您应该能够接收此数据作为 Source[T]
。