I am calling a api which returns xm response , but that response has around 2GB data , could you please help how should we call that in efficient way , now its failing to databuffer limit exceeds
below is the XML dto class
@XmlRootElement(name = "Result")
@lombok.Data
@AllArgsConstructor
@NoArgsConstructor
public class Result{
private List<Data> dataLisst;
}
@XmlRootElement(name = "Data")
@lombok.Data
@AllArgsConstructor
@NoArgsConstructor
public class Data {
private Integer id;
private String dataVersion;
private String name;
}
Below is the way i am calling Webclient its mono object response
@Service
public class WebclientXML {
public Result getXMLResult() {
return getWebClient()
.get()
.uri("/xml-resp/res")
.retrieve()
.bodyToMono(Result.class)
.block();
}
private WebClient getWebClient() {
return WebClient.builder()
.baseUrl("http://<host>:port")
.build();
}
}
Assuming your remote service responds with a collection of POJOs that Jackson can deserialize as Something.class, you can do something like:
@GetMapping(path = "/streaming", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@ResponseBody
public Flux<Something> streamSomething() {
return WebClient.create()
.get().uri("http://example.org/resource")
.retrieve().bodyToFlux(Something.class)
.delaySubscription(Duration.ofSeconds(5))
.repeat();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.