That would be helpful wouldn't it :-)

I am using Mina 2.0.0-M3


Thanks,

Steve Ash
Metavante Image Solutions
Software Developer
[EMAIL PROTECTED]

-----Original Message-----
From: Emmanuel Lecharny [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 03, 2008 10:51 AM
To: [email protected]
Subject: Re: Lifecycle of Server and Clients

Hi Steve,

which MINA version are you using ?

Steve Ash wrote:
> I am trying to create a simple client server application, and am a bit
> confused about the intended lifecycles of the acceptor and connector.
>
>  
>
> Currently, I am doing the following:
>
>  
>
> 1)      (Server) NioSocketAcceptor is created and my handler is set
>
> 2)      (Server) my codec factory is added via protocolfilterChain to
> the chain
>
> 3)      (Server) acceptor is bound to the server address/port and
> listens for incoming connections
>
> 4)      (Client) NioSocketConnector is created
>
> 5)      (Client) my codec factory is added via protocolFilterChain to
> the chain and the handler is set
>
> 6)      (Client) connects to the server and waitsUninteruptibly on the
> connectFuture
>
> 7)      Client and server exchange request, responses and every goes
> swimmingly (just writes, no waiting)
>
> 8)      (Client) is done, and sends a request to server indicating the
> he is done sending work (still just via write method, no
> waiting/blocking)
>
> 9)      (Client) calls session.close().waitUninterruptibly(...);
>
> 10)   (Server) gets the "done" request and does some business logic
> cleanup, then calls session.closeOnFlush();
>
> 11)   (Client) once the awaitUninterruptibly returns from the
> session.close future, calls connector.dispose();
>
>  
>
> So this is my lifecycle currently, and it is working except that it
> appears after my connector.dispose() is called, I get an exception on
> the server indicating it is writing to a closed socket.
>
>  
>
> 2008-10-31 15:53:26,591 WARN      server.SortStreamIoHandler : Session
> encountered a problem: 
>
> org.apache.mina.core.write.WriteToClosedSessionException
>
>       at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.clearWriteReques
> tQueue(AbstractPollingIoProcessor.java:521)
>
>       at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.removeNow(Abstra
> ctPollingIoProcessor.java:476)
>
>       at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.remove(AbstractP
> ollingIoProcessor.java:455)
>
>       at
> org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(Abstr
> actPollingIoProcessor.java:58)
>
>       at
> org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(Abstr
> actPollingIoProcessor.java:862)
>
>       at
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.j
> ava:51)
>
>       at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecuto
> r.java:885)
>
>       at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.ja
> va:907)
>
>       at java.lang.Thread.run(Thread.java:619)
>
>  
>
>  
>
> So I have a few questions that I didn't see clearly explained on the
> website that hopefully someone can clear up.
>
> 1)      When a client is "done" with his processing what is the intended
> way to end this exchange-the client closes the session, the server
> closes the session, both, or what?  This is where I am most confused
> about the intended lifecycle of sessions between the server and client.
>
> 2)      Do I always call connector.dispose() when I am ready to shut
> down the entire client or am I missing the point of this method?  If I
> don't call dispose, my application never quits as the connector thread
> doesn't exit.
>
> 3)      Should I be blocking in the client until the business logic
> "done" request comes back (i.e. block on the writeFuture)?  So that I
> don't close the session until after the server is done sending the "ok"
> for the "done" request.
>
> 4)      What is an example where you would not call dispose.  i.e. if
> you have a multithreaded client that all talks to the same server?
> Would these all go through the same connector?
>
>  
>
> Thanks so much for any help I can get!
>
>  
>
> Steve Ash
>
> Metavante Image Solutions
>
> Software Developer
>
> [EMAIL PROTECTED]
>
>  
>
>
>   


-- 
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to