mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@apache.org>
Subject Re: How to make IoAcceptor Multi thread
Date Wed, 10 Jun 2009 08:00:38 GMT

I guess that there is a mix of question and answer in this mail. Let's 
try to add some info ...

Andy Myint wrote:
> Do I need to make my IoHandler thread-safe?
> It depends on your implementation. If you access the resource which is
> shared across multiple sessions, you have to make it thread-safe. If the
> resource is not shared at all and accessed by only one session (e.g. storing
> context information as a session attribute), then you don't need to make it
> thread-safe. It is because all events generated by MINA are transmitted to
> your handler in order (when using the Executor Filter), and the newer event
> is not processed if the event handler method for the older event for the
> same session hasn't returned yet.
I would add that you must use MINA-2.0.0-M6, the previous versions have 
bugs in this area.
> IoAcceptor is processing message in order.
Not exactly the acceptor. NioProcessor are processing incoming and 
outgoing message for an established connection (session).
>  How can I make IoAcceptor send
> event to iohandler asynchronously so that iohandler will be receving events
> without having to wait for previous one to be finished. Following is my
> spring config.
You can use an executorFilter with a UnorderedThreadPoolExecutor.

Keep in mind that the IoHandler don't wait for events. IoHandler are 
called when some events are present.
>     <bean id="ioAcceptorUDP"
> class="org.apache.mina.transport.socket.nio.NioDatagramAcceptor"
> init-method="bind" destroy-method="unbind">
>         <property name="defaultLocalAddress" value="${listener.port.udp}" />
>         <property name="handler" ref="udpHandler" />
>         <property name="filterChainBuilder" ref="filterChainBuilder" />
>     </bean>

cordialement, regards,
Emmanuel L├ęcharny

View raw message