Salut,
rama.rama_at_tiscali.it wrote:
> i am having some trouble with suspend/resume for a request.
>
>
> let's
> start :)
>
> --all pseudo code--
>
>
> test(final GrizzlyRequest httpReq,
> final GrizzlyResponse httpResp,HttpSession session) {
>
>
> if (!httpResp.isSuspended()) {
> if (!session.haveMsg())
> {
> httpResp.suspend(30000,this,new
> CompletionHandler<EulerResAdapter>() {
> public
> void resumed(EulerResAdapter attachment) {
>
> attachment.service(httpReq,httpResp);
>
> }
> public void
> cancelled(EulerResAdapter attachment) {
>
> attachment.service(httpReq,httpResp);
> }
The cancelled and resumed does the same?
>
> });
> //add to queue for later
> resuming
> return;
> }
> }
>
>
> <BLABLABLA(will explain later)>
> }
>
>
> basically, what
> this test request do is
> check if a RESP is suspended, if not, check if
> there are msg for this session.
> if there isn't any msg, wait for 30000,
> and try again.
>
>
> work like a charm, in the meaning that the request is
> suspended when needed, and resumed when needed
> (ie: if someone put a
> msg on session, the request is resumed correctly)
Of so far so good :-)
>
> After that i use
> something like (the BLABLABLA PART)
>
> Element req = Parser.read(httpReq.
> getReader());
>
> that normally (without suspension) work like a charm
>
> Parser is a static class that parse an xml using dom4j
>
>
> When a request
> is suspended and later resumed
> the line "Parser.read(httpReq.
> getReader())"
> say
> ----Stream closed Nested exception: Stream closed
Yes, because the response has been committed when you invoke resume().
For you use case, just don't resume the connection and it will works.
Thanks
-- Jeanfrancois
>
>
> So, seems that i am not able to read the stream with a getReader on the
> httpRequest.
>
> i can easilly workaroud to this problem probably,
> i can
> parse BEFORE the xml, then add to the session the XML, and then,
> executing the request as normal.
> but, seem a bit hugly, and i can't
> understand why i can't read the httpReq later.
>
> Tnx for help!
>
>
>
>
> Con Tutto Incluso chiami e navighi senza limiti e hai 4 mesi GRATIS.
>
> L'attivazione del servizio è gratis e non paghi più Telecom!
>
> L'offerta è valida solo se attivi entro il 02/04/09 http://abbonati.tiscali.it/promo/tuttoincluso/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>