Look for stream caching doc
https://camel.apache.org/manual/stream-caching.html
https://github.com/apache/camel-spring-boot-examples/tree/main/http-streaming


Em ter., 28 de out. de 2025 às 11:36, KARTHIK PRABHU N
<[email protected]> escreveu:
>
> Hello Team,
>
> I have created a below route – exposed as rest endpoint using servlet
> component and calling GCP API to download object using http component. We
> want response to be streamed as it is very large object.
>
>
>
> The below logic downloads object as byte which will end up in max heap
> consumption. Could you please assist what is wrong with the below route.
>
> I am using camel core version 4.8.
>
> .from("{{exposed as rest endpoint using servlet component}}")
>
>             .setHeader(Exchange.DISABLE_HTTP_STREAM_CACHE, constant(true))
>
>             // Set correct GCS object URL
>
>             .setHeader(Exchange.HTTP_URI, simple(
>
>
> https://storage.googleapis.com/{{bucketName}}/?responsePayloadStreamingThreshold=-1
>
>             ))
>
>            // Use http component for streaming
>
>             .to(http://dummy)
>
>
>
>            // Forward content type if available
>
>             .process(exchange -> {
>
>                         InputStream responseStream =
> exchange.getMessage().getBody(InputStream.class);
>
>                         exchange.getMessage().setBody(responseStream);
>
>                         String contentType =
> exchange.getMessage().getHeader("Content-Type", String.class);
>
>                         exchange.getMessage().setHeader("Content-Type",
> contentType != null ? contentType : "application/octet-stream");
>
>
> exchange.getMessage().setHeader("Transfer-Encoding", "chunked");
>
>             })
>
>
>
>
>
>             .end(); // stream response to client
>
>
>
>
>
> Thank you !
>
> Karthik



-- 
  Claudio Miranda

[email protected]
http://www.claudius.com.br

Reply via email to