Ashish,

Thanks! Looking forward to the example/doc. 

I did figure out why the exception.

If request time out is set too short (10 milliseconds), then the request timed 
out before response come back. So the round trip >= 10 milliseconds on the same 
machine. Is it reasonable? It seems a bit long to me.

If request time out is reasonable, then client main exit, but timeoutScheduler 
is not shutdown in the OnPostRemove method of RequestResponseFilter. I think 
this might be a minor bug. Shall I open  JIRA? 


Thanks.

Haijun

 

-----Original Message-----
From: Ashish [mailto:[email protected]] 
Sent: Monday, August 10, 2009 8:39 PM
To: [email protected]
Subject: Re: RequestResponseFilter

Don't get disappointed :-)

I am working on it. Plan to add an example as well as documentation
for the same on wiki.

Its part of JIRA issue DIRMINA-593.

thanks
ashish

On Tue, Aug 11, 2009 at 7:02 AM, Haijun Cao<[email protected]> wrote:
>
> Hmm, no response. I hope I am posting to the right place.
>
> OK, With a few trial and error, I seem to get reqres to work (more or
> less).
>
> However, I found that the setting of request timeout impact the client
> behavior in ways I can't understand. I assume that I should have the
> same behavior with the sumup example, start the server, start the
> client, client exit by itself and result is printed out in the log. The
> test shows otherwise.
>
> My test program is a minor modification of the sumup example (add the
> reqres filter):
>
> In ClientSessionHandler.java:
>
> public class ClientSessionHandler extends IoHandlerAdapter {
>
>    public static class Inspector implements ResponseInspector {
>        public Object getRequestId (Object message) {
>            AbstractMessage am = (AbstractMessage)message;
>            return Integer.valueOf(am.getSequence());
>        }
>        public ResponseType getResponseType (Object message) {
>            return ResponseType.WHOLE;
>        }
>    }
> ...
>   �...@override
>    public void sessionOpened(IoSession session) {
>        // send summation requests
>        for (int i = 0; i < values.length; i++) {
>            AddMessage m = new AddMessage();
>            m.setSequence(i);
>            m.setValue(values[i]);
>            Request req = new Request (Integer.valueOf(i), m, 10); <--
> timeout set to 10 milliseconds
>            session.write(req);
>        }
>    }
> ...
>   �...@override
>    public void messageReceived(IoSession session, Object message) {
>        // server only sends ResultMessage. otherwise, we will have to
> identify
>        // its type using instanceof operator.
>        Response res = (Response)message;
>        ResultMessage rm = (ResultMessage) res.getMessage();
>        if (rm.isOk()) {
> ...
>
>
> In Client.java:
> ...
>        connector.getFilterChain().addLast("logger", new
> LoggingFilter());
>        connector.getFilterChain().addLast ("reqres",
>                                          new RequestResponseFilter(new
> ClientS\
> essionHandler.Inspector(), new ScheduledThreadPoolExecutor(2)));
> ...
>
>
> I found that if I set the request timeout to be 1000, then I got sum
> result in the log, but Client program won't exit (session can't be
> closed?). If I set the request timeout to 10, then I got
> WriteToClosedSessionException.
>
> I'd really appreciate if somebody can point me to the right direction on
> how to use reqres filter correctly.
>
>
> Thanks
> Haijun
>
>
> 2009-08-11 01:15:20,490 INFO  [NioProcessor-1]
> reqres.ClientSessionHandler The sum: 10
>
>
> 2009-08-11 01:23:02,007 WARN  [NioProcessor-1] logging.LoggingFilter
> EXCEPTION :
> org.apache.mina.core.write.WriteToClosedSessionException
>        at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.clearWriteReques
> tQueue(AbstractPollingIoProcessor.java:539)
>        at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.removeNow(Abstra
> ctPollingIoProcessor.java:492)
>        at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.remove(AbstractP
> ollingIoProcessor.java:471)
>        at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(Abstr
> actPollingIoProcessor.java:56)
>        at
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(Ab
> stractPollingIoProcessor.java:896)
>        at
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.j
> ava:64)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecuto
> r.java:886)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.ja
> va:908)
>        at java.lang.Thread.run(Thread.java:619)
>
>
>
>
>
> -----Original Message-----
> From: Haijun Cao [mailto:[email protected]]
> Sent: Monday, August 10, 2009 12:09 PM
> To: [email protected]
> Subject: RequestResponseFilter
>
> Hi
>
>
>
> I am new to MINA. I am considering when RequestResponseFilter class,
> wondering if somebody can give me some example code on how to use it?
>
>
>
>
>
>
>
> Thanks
>
>
>
> Haijun
>
>



-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Reply via email to