Michael Bauroth wrote:
> Hi,
>
> I've found in one of the last examples the following config snippet:
>
> <bean id="filterChainBuilder"
> class="org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean">
>
>   <property name="filters">
>     <list>
>       <bean class="org.apache.mina.filter.thread.ThreadPoolFilter">
>       <!-- Threads will be named IoWorker-1, IoWorker-2, etc -->
>         <constructor-arg value="IoWorker"/>
>         <property name="maximumPoolSize" value="16"/>
>         <property name="keepAliveTime" value="60000"/>
>       </bean>
>      ...
>
> Unfortunately this code doesn't work anymore because of changes of the
> underlying class I think. What can I do?
>
Here's what you need to do:

Put this anywhere in your Spring config

<bean id="org.apache.mina.common.ThreadModel.MANUAL"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>


When you configure your SocketAcceptorConfig be sure to set the
threadModel to MANUAL otherwise MINA will create a ThreadPoolFilter for you

<bean class="org.apache.mina.transport.socket.nio.SocketAcceptorConfig">
  <property name="reuseAddress" value="true"/>
  <property name="threadModel"
ref="org.apache.mina.common.ThreadModel.MANUAL"/>
</bean>

Then you need to change your XML above into

<bean class="org.apache.mina.filter.thread.ThreadPoolFilter">
  <constructor-arg>
    <bean class="org.apache.mina.filter.thread.LeaderFollowersThreadPool">
      <!-- Threads will be named IoWorker-1, IoWorker-2, etc -->
      <constructor-arg value="IoWorker"/>
      <property name="maximumPoolSize" value="16"/>
      <property name="keepAliveTime" value="60000"/>
    </bean>
  </constructor-arg>

An alternative to the changes above would be to configure your own
PooledThreadModel and remove the ThreadPoolFilter configuration:

<bean class="org.apache.mina.transport.socket.nio.SocketAcceptorConfig">
  <property name="reuseAddress" value="true"/>
  <property name="threadModel">
    <bean class="org.apache.mina.common.PooledThreadModel">
      <property name="threadNamePrefix" value="IoWorker"/>
      <property name="maximumPoolSize" value="16"/>
      <property name="keepAliveTime" value="60000"/>
    </bean>
  </property>
</bean>

Thanks for bringing this to my attention. I have updated the Javadoc for
IoAcceptorFactoryBean.

I think I will have to look into how we can simplify the Spring
integration further. With the introduction of ThreadModel and the
generalization of ThreadPoolFilter the Spring integration has been a lot
more complicated.

-- 
Niklas Therning
Software Architect
www.spamdrain.net

Reply via email to