I am having some questions about consuming a Spring WebFlux application from a Play Framework application, over HTTP, could you please provide some help?
Micro service A is a reactive Spring WebFlux, written in Java 8, SpringBoot 2.1.4, it is exposing this API:
@Autowired private ReactiveCustomerRepository customerRepository;
@GetMapping("/customers")
public Flux<Customer> getAllCustomers() {
Flux<Customer> c = customerRepository.findAll().delayElements(Duration.ofMillis(5000));
return c;
}
I would like to consume this, in a reactive way from a Play Framework micro service B, over HTTP.
Could you please provide some advices or a small snippet on how to achieve this please?
Thank you for your help.
You can try to use different content-type that supports streaming - application/stream+json
. Spring WebFlux will serialize individual Flux elements and send them one by one over the wire. Check out the following SO thread about it: Spring WebFlux Flux behavior with non streaming application/json
On the play-ws side you should be able to receive this data as Source[T]
.