Hi mat,
On 4/19/07, mat <[EMAIL PROTECTED]> wrote:
Dear all,
I am using mina as both server and client in my service. I just wonder if I
should use IO/service(process) threads provided by mina to handle the
business logic?
what I understood is:
I added config.getFilterChain().addLast("threadPool", new ExecutorFilter(
Executors.newCachedThreadPool())) at server.
There's no direct relationship between implementing business logic and
adding an executor filter to the filter chain. You can execute the
business logic in your IoHandler even if you didn't add an executor
filter. An executor filter is required only the the business logic
performs a blocking operation such as database access.
Probably most business logic will involve external resources like
database, you are likely to add an executor filter.
1) If client connector also needs config.getFilterChain().addLast("threadPool",
new ExecutorFilter(Executors.newCachedThreadPool())) ? If so, how to control
the numbers of threads for both servers and clients in order to reach the
maxiuam performance. I have 4, 5 client connections.
If you want to control the maximum number of threads, you will have to
create a different Executor that just
'Executors.newCachedThreadPool()'. You need to consult the JavaDoc of
java.util.concurrent.Executors class.
MINA executor filter ensures only one event is processed per session,
so you will have 5 active thread at max even if you used
Executors.newCachedThreadPool().
Again, creating an executor is what MINA does but you do. Please
check the Java SE API documentation.
2) Since in my application, the data is big. What if mina IO/Process CAN'T
handle them in time? Put them in the mina internal queue? Or drop them? I
really worry about the memory problem.
If the data is too big to load the whole data into the heap, things
become tricky. People usually split the big data into multiple
messages.
3) If i use IO/process threads, the messageReceived methods will be called
asychronized. Am I right? If so, how can I make sure the incoming events is
processed in order?
I don't get your question here. MINA can't do anything without I/O
processor threads.
Anyway, the order of events is always maintained correctly. You don't
need to worry one message arrives before the other arrives.
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6