How to send data by writing into output stream?

49 views
Skip to first unread message

Johannes Schneider

unread,
Dec 12, 2016, 7:28:21 AM12/12/16
to jooby-project
Hey guys,

I want to stream a lot of data. Therefore I'd need an output stream where I can write my data to.
Unfortunately I could not find a way how to get that...

Any ideas?


Thanks,

Johannes

Edgar Espina

unread,
Dec 12, 2016, 8:02:54 AM12/12/16
to jooby-project
What type of data is it?

There is support for InputStream:

get("/", () -> {
 
InputStream stream = ...;
 
return stream;
});

But not for output streams.

Johannes Schneider

unread,
Dec 12, 2016, 9:37:25 AM12/12/16
to jooby-project
I want to sent binary data to the client. And I really would like to write the data to the output stream - else I had to keep the data in memory.

The org.jooby.servlet.ServletServletResponse#send() methods use rsp.getOutputStream() which is all I need.


So could you create a way to get a reference to that output stream?

Edgar Espina

unread,
Dec 12, 2016, 10:16:52 AM12/12/16
to jooby-project
That is just for Servlet/Jetty, isn't that simple for Netty & Undertow.

Still, think this will be useful. Can you please file this at github?

Thanks

Victor J. Reventos

unread,
Nov 27, 2018, 5:56:02 PM11/27/18
to jooby-project
Hi Edgar,

I would love to see this feature. Currently I would like to write directly to the output stream, instead of buffering the full payload in memory. I'm deploying this an environment with very limited memory and I'm using Jooby for routing and marshalling.

What makes it difficult to implement this with Netty & Undertow?

Thanks,

Victor J. Reventos

Edgar Espina

unread,
Nov 27, 2018, 6:00:13 PM11/27/18
to victor.r...@gmail.com, jooby-...@googlegroups.com
Something I'm considering for 2.x

What is the source of your data? Jooby efficiently send data from inputstream or file system.

--
You received this message because you are subscribed to the Google Groups "jooby-project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooby-projec...@googlegroups.com.
To post to this group, send email to jooby-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooby-project/a879b225-6ada-4b50-8c0f-75248c675349%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
edgar

Victor J. Reventos

unread,
Nov 27, 2018, 6:09:50 PM11/27/18
to Edgar Espina, jooby-...@googlegroups.com
I have some in memory structures tightly packed into arrays. Creating an Object model to serialize it via JSON would create a lot of unnecessary references, which isn't something the current system can withstand.

Hence, I need an API to push data, instead of the current one using InputStream/Reader which is more of pull model.

I can also try to do a PR if necessary.

Edgar Espina

unread,
Nov 27, 2018, 6:22:00 PM11/27/18
to victor.r...@gmail.com, jooby-...@googlegroups.com
Sounds like a good idea and happy to review and merge it.
--
edgar

Victor J. Reventos

unread,
Nov 27, 2018, 6:46:34 PM11/27/18
to Edgar Espina, jooby-...@googlegroups.com
You mentioned doing this would be difficult for Netty. Why would that be the case? Is there something I'm missing?

Edgar Espina

unread,
Nov 27, 2018, 7:15:55 PM11/27/18
to Victor J. Reventos, jooby-...@googlegroups.com
Don't remember :(
Reply all
Reply to author
Forward
0 new messages