directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <nik...@trillian.se>
Subject Re: Understand thread usage in MINA
Date Thu, 09 Feb 2006 14:56:27 GMT
william.poitras@thomson.com wrote:
> I’d like to understand thread usage better in MINA.
> 
>  
> 
> I have an application in mind that accepts TCP connections on one of 
> several ports and can also initiate connections to another server that 
> talks the same protocol.  Its basically a server to server messaging system.
> 
>  
> 
> For accepting connections I would register a Service with each port I’m 
> listening on, and for making the outbound connections I would use a 
> SocketConnector to connect to the other servers.  The questions I have is:
> 
>  
> 
> -          Do all of the Service objects share the same thread pool?

If you use SimpleServiceRegistry a default unbounded thread pool will be 
used for all Service objects. However, the thread pool is just an 
IoFilter which gets added to each IoSession's (incoming connection's) 
filter chain and you have full control over the filter chains so this 
can be changed if needed.

> -          Does all of the connections created from a SocketConnector 
> share the same thread pool? Is this the same pool that the Service 
> objects use?

No, SocketConnector doesn't use a thread pool by default. You will have 
to pass a custom IoFilterChainBuilder when calling connect() which adds 
a ThreadPoolFilter to the filter chains' of sessions or you could add 
the ThreadPoolFilter in the sessionCreated() method in you IoHandler.

> -          Would I use 1 socket connector for the entire application?  A 
> pool of them?  One per client?

A single connector will suffice. You should use a ThreadPoolFilter for 
the sessions created from it.

> 
> --bill
> 

HTH
/Niklas

Mime
View raw message