[xwiki-users] buffering?
Hello XWiki experts, I'm implementing OAI-PMH, a service infrastructure to aggregate digital library items. I do so with a few velocity pages and a groovy page. I'll happily share it. At first, I did not implement the "resumption" flow-control, which allows a big search list to be paged in several requests as I expected the output of my velocity script to trigger a buffer-full and start delivering the packets down the line. But this fails, nothing comes before it's finished. And indeed, I receive a content-length header... so there is buffering happening somewhere. Do I have a possibility to disable velocity output buffering? Paul
On 12/17/2012 12:31 PM, Paul Libbrecht wrote:
Hello XWiki experts,
I'm implementing OAI-PMH, a service infrastructure to aggregate digital library items. I do so with a few velocity pages and a groovy page. I'll happily share it. At first, I did not implement the "resumption" flow-control, which allows a big search list to be paged in several requests as I expected the output of my velocity script to trigger a buffer-full and start delivering the packets down the line.
But this fails, nothing comes before it's finished. And indeed, I receive a content-length header... so there is buffering happening somewhere.
Do I have a possibility to disable velocity output buffering?
It's not Velocity that's buffering, it's the whole rendering engine that does that. Velocity itself is just one of the steps through which document content passes, and each step outputs everything in a buffer which is later flushed down the socket after every rendering step is finished. At least that's what's happening if you use the rendering engine to "run" code from wiki documents. -- Sergiu Dumitriu http://purl.org/net/sergiu
It's not Velocity that's buffering, it's the whole rendering engine that does that. Velocity itself is just one of the steps through which document content passes, and each step outputs everything in a buffer which is later flushed down the socket after every rendering step is finished.
At least that's what's happening if you use the rendering engine to "run" code from wiki documents.
Is there any way to disable buffering at each of the steps? I'm thinking this may have a performance impact. However, for my case, implementing OAI-PMH, I've solved it by using the "query resumption" that the protocol offers. paul
On 12/19/2012 01:33 PM, Paul Libbrecht wrote:
It's not Velocity that's buffering, it's the whole rendering engine that does that. Velocity itself is just one of the steps through which document content passes, and each step outputs everything in a buffer which is later flushed down the socket after every rendering step is finished.
At least that's what's happening if you use the rendering engine to "run" code from wiki documents.
Is there any way to disable buffering at each of the steps?
No, especially not with the current (XRendering) rendering engine, since Velocity is just a Transformation that works on the XDOM, which will be actually transformed into real output in a separate process that expects a final, full DOM.
I'm thinking this may have a performance impact.
Yes, it does.
However, for my case, implementing OAI-PMH, I've solved it by using the "query resumption" that the protocol offers.
It's good that you found a workaround. -- Sergiu Dumitriu http://purl.org/net/sergiu
On Wed, Dec 19, 2012 at 7:38 PM, Sergiu Dumitriu <[email protected]> wrote:
On 12/19/2012 01:33 PM, Paul Libbrecht wrote:
It's not Velocity that's buffering, it's the whole rendering engine that does that. Velocity itself is just one of the steps through which document content passes, and each step outputs everything in a buffer which is later flushed down the socket after every rendering step is finished.
At least that's what's happening if you use the rendering engine to "run" code from wiki documents.
Is there any way to disable buffering at each of the steps?
No, especially not with the current (XRendering) rendering engine, since Velocity is just a Transformation that works on the XDOM, which will be actually transformed into real output in a separate process that expects a final, full DOM.
That's true but it does not prevent you to write directly in the response if you want. Something like: ## Get the response buffer/stream #set($out = $response.outputStream()) ## Write some content to the response buffer $out.print("some content") ## Make sure everything is sent $out.flush() ## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)
I'm thinking this may have a performance impact.
Yes, it does.
However, for my case, implementing OAI-PMH, I've solved it by using the "query resumption" that the protocol offers.
It's good that you found a workaround. -- Sergiu Dumitriu http://purl.org/net/sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
That's true but it does not prevent you to write directly in the response if you want.
Something like:
## Get the response buffer/stream #set($out = $response.outputStream())
## Write some content to the response buffer $out.print("some content")
## Make sure everything is sent $out.flush()
## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)
Hey, we're getting closer! How does this play with the velocity execution? Would its output be discarded then? I've tried this: $response.setContentType("text/plain")## #set($out = $response.outputStream())## ## Write some content to the response buffer $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content") ## Make sure everything is sent $out.flush()## ## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)## and had only blank pages/ Paul
On Thu, Dec 20, 2012 at 11:00 AM, Paul Libbrecht <[email protected]> wrote:
That's true but it does not prevent you to write directly in the response if you want.
Something like:
## Get the response buffer/stream #set($out = $response.outputStream())
## Write some content to the response buffer $out.print("some content")
## Make sure everything is sent $out.flush()
## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)
Hey, we're getting closer!
How does this play with the velocity execution? Would its output be discarded then?
I've tried this:
$response.setContentType("text/plain")## #set($out = $response.outputStream())## ## Write some content to the response buffer $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content") ## Make sure everything is sent $out.flush()## ## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)##
and had only blank pages/
That's because you did not really wrote anything ;) I made a mistake in my example, it's #set($out = $response.outputStream) without the parentheses.
Paul _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
great, that worked. However, it means the velocity output is forgotten so I'd have to call velocity at places where it makes sense. I'm also caught by this kind of things, the "eat all exceptions" type of approach of velocity is not a charm! It's good to know as a strategy for the future. paul Le 20 déc. 2012 à 12:00, Thomas Mortagne a écrit :
On Thu, Dec 20, 2012 at 11:00 AM, Paul Libbrecht <[email protected]> wrote:
That's true but it does not prevent you to write directly in the response if you want.
Something like:
## Get the response buffer/stream #set($out = $response.outputStream())
## Write some content to the response buffer $out.print("some content")
## Make sure everything is sent $out.flush()
## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)
Hey, we're getting closer!
How does this play with the velocity execution? Would its output be discarded then?
I've tried this:
$response.setContentType("text/plain")## #set($out = $response.outputStream())## ## Write some content to the response buffer $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content") ## Make sure everything is sent $out.flush()## ## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)##
and had only blank pages/
That's because you did not really wrote anything ;)
I made a mistake in my example, it's
#set($out = $response.outputStream)
without the parentheses.
Paul _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Thomas, all, would I have a way to invoke velocity using the scope being run but without the rendering? I guess that would be the exact use case here and it is likely to be so for other people; for example to generate xml documents, json documents... thanks in advance. paul Le 20 déc. 2012 à 12:46, Paul Libbrecht a écrit :
great, that worked.
However, it means the velocity output is forgotten so I'd have to call velocity at places where it makes sense.
I'm also caught by this kind of things, the "eat all exceptions" type of approach of velocity is not a charm!
It's good to know as a strategy for the future.
paul
Le 20 déc. 2012 à 12:00, Thomas Mortagne a écrit :
On Thu, Dec 20, 2012 at 11:00 AM, Paul Libbrecht <[email protected]> wrote:
That's true but it does not prevent you to write directly in the response if you want.
Something like:
## Get the response buffer/stream #set($out = $response.outputStream())
## Write some content to the response buffer $out.print("some content")
## Make sure everything is sent $out.flush()
## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)
Hey, we're getting closer!
How does this play with the velocity execution? Would its output be discarded then?
I've tried this:
$response.setContentType("text/plain")## #set($out = $response.outputStream())## ## Write some content to the response buffer $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content") ## Make sure everything is sent $out.flush()## ## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)##
and had only blank pages/
That's because you did not really wrote anything ;)
I made a mistake in my example, it's
#set($out = $response.outputStream)
without the parentheses.
Paul _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
On 12/21/2012 10:39 AM, Paul Libbrecht wrote:
Thomas, all,
would I have a way to invoke velocity using the scope being run but without the rendering? I guess that would be the exact use case here and it is likely to be so for other people; for example to generate xml documents, json documents...
thanks in advance.
It is possible, but not with what's available out of the box. You would have to write a new action that is only responsible for invoking Velocity, connecting its output directly to the socket. -- Sergiu Dumitriu http://purl.org/net/sergiu/
would I have a way to invoke velocity using the scope being run but without the rendering? I guess that would be the exact use case here and it is likely to be so for other people; for example to generate xml documents, json documents...
It is possible, but not with what's available out of the box. You would have to write a new action that is only responsible for invoking Velocity, connecting its output directly to the socket.
Really? No, if I seize the response and outputstream from a velocity script in the page, as mentioned earlier, I have all the necessary sockets and connection. Now I'd like something such as "includeThisPagesVelocityCode" (which could be loaded as string even) which would output right out into the stream. paul
On Fri, Dec 21, 2012 at 4:39 PM, Paul Libbrecht <[email protected]> wrote:
Thomas, all,
would I have a way to invoke velocity using the scope being run but without the rendering? I guess that would be the exact use case here and it is likely to be so for other people; for example to generate xml documents, json documents...
Not sure I fully undertand what you ask, when you use $xcontext.setFinished(true) you will get only when you wrote directly to the output stream. I'm using it to generate translation packages in l10n.xwiki.org for example.
thanks in advance.
paul
Le 20 déc. 2012 à 12:46, Paul Libbrecht a écrit :
great, that worked.
However, it means the velocity output is forgotten so I'd have to call velocity at places where it makes sense.
I'm also caught by this kind of things, the "eat all exceptions" type of approach of velocity is not a charm!
It's good to know as a strategy for the future.
paul
Le 20 déc. 2012 à 12:00, Thomas Mortagne a écrit :
On Thu, Dec 20, 2012 at 11:00 AM, Paul Libbrecht <[email protected]> wrote:
That's true but it does not prevent you to write directly in the
response
if you want.
Something like:
## Get the response buffer/stream #set($out = $response.outputStream())
## Write some content to the response buffer $out.print("some content")
## Make sure everything is sent $out.flush()
## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)
Hey, we're getting closer!
How does this play with the velocity execution? Would its output be discarded then?
I've tried this:
$response.setContentType("text/plain")## #set($out = $response.outputStream())## ## Write some content to the response buffer $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content")## $out.println("some content") ## Make sure everything is sent $out.flush()## ## Indicate XWiki that you already sent the answer $xcontext.setFinished(true)##
and had only blank pages/
That's because you did not really wrote anything ;)
I made a mistake in my example, it's
#set($out = $response.outputStream)
without the parentheses.
Paul _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
participants (3)
-
Paul Libbrecht -
Sergiu Dumitriu -
Thomas Mortagne