Qute Template Rendering with Streaming to Avoid Huge Heap-Memory Consumption in case of Large HTML #41566
-
Hello Quarkus Team, i would like to ask, how i could use the Qute Template Engine with a Streaming-Approach, I need this to be able to generate huge HTML-Files that i want to transform to PDF files (containing 100 of pages). I dont know if it is possible to render HTML in Chunks / Streams, but if it is possible, then it should be very low in memory usage because the Stream will be immediately consumed. In the docs there seems to be no streaming support for rendering. See: A "OutputStream", "ByteArrayOutputStream" or similar would be great. Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
/cc @mkouba (qute) |
Beta Was this translation helpful? Give feedback.
-
As you already found out there are several ways how to trigger rendering and consume the rendered result. For your use case, the However, keep in mind that in Qute the result tree is always built during rendering. So there would be still some memory overhead involved. |
Beta Was this translation helpful? Give feedback.
-
@mkouba |
Beta Was this translation helpful? Give feedback.
As you already found out there are several ways how to trigger rendering and consume the rendered result. For your use case, the
TemplateInstance#consume(Consumer<String>)
method looks like a good match. The consumer is invoked whenever a chunk is available and the returned completion stage that is completed once the rendering finished.However, keep in mind that in Qute the result tree is always built during rendering. S…