Is it possible to stream large data (object) in spring

169 Views Asked by At

We construct a large object currently in java and send it as text/xml. It seems the client times out. Is it possible to convert this object in byte array or String and stream the data. Will it help? We are using spring boot.

1

There are 1 best solutions below

0
Armen Arzumanyan On

You should use TEXT_EVENT_STREAM_VALUE with Spring reactive, but it is expensive(too much CPU/Memory)

Ideally spring controlller should return

 return quasarService.findByReceivedStatus(organizationId, receiverId)
                .delayElements(Duration.ofSeconds(delay))
                .cache()
                .take(50)
                .onBackpressureDrop()               
                .repeat(3) /// if repeat number not specified connection will keep long..
.parallel(50); //ParallelFlux