You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Steven <xi...@126.com> on 2008/03/18 07:46:57 UTC

How to use the ExecutorFilter class?

Is there any examples?

Should I create an class that extends the ExecutorFilter class and then add this class to the filter chain?

In my situation, I have clients that will send some command to the server programme, once the server has received the command, it will do some database works that will cost lots of time, and when these db works have been done, the server will send a response message to the client who is waiting for this message.

Is it proper to create an class that extends the ExecutorFilter class and do the db works in this class' messageReceived and messageSent methods?

Thank you!

Steven

 
 
 
 

Re:Re: How to use the ExecutorFilter class?

Posted by Steven <xi...@126.com>.
 
Thank you Niklas,

I will look at the codes you recommended.

As far as I know, there is one IoHandler for one IoPorcessor thread if no ExecutorFilter is inserted into the filter chain, is that correct?

If I insert the ExecutorFilter into to the filter chain, then what's the relationship between the IoHander threads (or the ExecturoFilter threads) and the IoProcessor threads?

And if the actual works are done in the IoHandler, then if I have lots of clients connect to the server concurrently, will it make some clients' request to be wait until the other clients' request have been deal with?

My original idea is to do the actual database works in some other threads but not using the ExecutorFilter, and then using the BlockingQueue to exchange information between these worker threads and the IoHander threads. But if the client has to wait for the server's response message, then it seems that this method is not so efficiently, I doubt that the IoHandler will be blocked when it is waiting for the workers thread's response, so that will make the other clients' request can not be accessed in time.

Thanks.

Steven

 
 

在2008-03-18,"Niklas Gustavsson" <ni...@protocol7.com> 写道:

On Tue, Mar 18, 2008 at 7:46 AM, Steven <xi...@126.com> wrote:
>  Is it proper to create an class that extends the ExecutorFilter class and do the db works in this class' messageReceived and messageSent methods?

No, you would do the actual work in your IoHandler. The ExecutorFilter
you would insert directly into the filter chain. You can have a look
at how we use it in FtpServer which is kind of similar as some data
transfers can take a lot of time:
http://svn.apache.org/repos/asf/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/mina/MinaListener.java

/niklas

Re: How to use the ExecutorFilter class?

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Tue, Mar 18, 2008 at 7:46 AM, Steven <xi...@126.com> wrote:
>  Is it proper to create an class that extends the ExecutorFilter class and do the db works in this class' messageReceived and messageSent methods?

No, you would do the actual work in your IoHandler. The ExecutorFilter
you would insert directly into the filter chain. You can have a look
at how we use it in FtpServer which is kind of similar as some data
transfers can take a lot of time:
http://svn.apache.org/repos/asf/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/listener/mina/MinaListener.java

/niklas