I'm playing a bit with WebFlux and Spring 5 just to get acquainted with reactive paradigm... it's something I'm not used to use, I think it will take a fairly amount of time to be really mastered.
My first question: I developed a REST endpoint using Flux and FluxSink to dinamically generate data to be sent to the client. I developed the endpoint so that a random amount of time elapses between two subsequent calls of fluxsink.next(item) method.
As expected, if i issue a GET on the enpoint via CURL, I see that JSON entities are "streamed" as soon as they're created in the flux; I'd like to get the same effect via PostMan, but at the moment I've only been able to get all the data all together, when the fluxsing.complete() method is invoked.
REST endpoint is declared to produce an 'application/x-ndjson' mime type.
Any suggestion ?
Ron McLeod wrote:I've never heard of application/x-ndjson (newline-delimited JSON) before - it is something specific to Spring?
I dont' think it's spring-specific, but to be honest I've also never heard of it before.
Ron McLeod wrote:For streaming, I would normally use SSE or WebSockets to a browser, or gRPC (HTTP/2) to stream between services.
Yes, I also used to use websockets. I'm just doing some experiments with webflux. This is a code snipped of which I've done so far :
Please note that I'm not even sure if in a Rest Api we could use streaming. On the opposite, I'm afraid that, even if a similar approach will work, it would be against any REST principle.
Here Customer is a simple bean, irrelevant with respect the specific use case (it's just a plain bean). I would expect to get a bean every 1 second, but as I described above, I can only get the whole bunch of 10 customers.
Ron McLeod wrote:
There was an issue opened almost 4 years ago regarding streaming result support in Postman (specifically SSE) - looks like it still has not been addressed.
At the moment I tried also Google ARC (advanced rest client), with no better luck; honestly I didn't investigate ARC further, normally I use Postman even for work and I'd prefer keep focused on a single testing tool.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop