Hi Raju,
On 5/30/07, Raju Mohanapu <[EMAIL PROTECTED]> wrote:
Hello Maarten,
Many thanks for a prompt response.
Here is the snippet of our spring config.
****Server Side****
<bean id="org.apache.mina.common.ThreadModel.MANUAL"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean
"/>
<bean id="smppFilterThreadPoolFactory"
class="org.apache.mina.integration.spring.ThreadPoolExecutorFactoryBean">
<property name="corePoolSize" value="10"/>
<property name="maxPoolSize" value="15"/>
<property name="keepAliveSeconds" value="30"/>
</bean>
<bean id="smppFilterChainBuilder"
class="
org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean
">
<property name="filters">
<list>
<bean class="org.apache.mina.filter.executor.ExecutorFilter">
<constructor-arg>
<ref bean="smppFilterThreadPoolFactory"/>
</constructor-arg>
</bean>
<bean class="org.apache.mina.filter.codec.ProtocolCodecFilter">
<constructor-arg ref="smppProtocolCodecFactory"/>
</bean>
<bean class="org.apache.mina.filter.LoggingFilter"/>
</list>
</property>
</bean>
<bean id="smppSocketAcceptorConfig"
class="org.apache.mina.transport.socket.nio.SocketAcceptorConfig">
<property name="filterChainBuilder" ref="smppFilterChainBuilder"/>
<property name="threadModel"
ref="org.apache.mina.common.ThreadModel.MANUAL"/>
<property name="reuseAddress" value="true"/>
</bean>
<bean id="ioAcceptor"
class="org.apache.mina.integration.spring.IoAcceptorFactoryBean">
<property name="target">
<bean class="org.apache.mina.transport.socket.nio.SocketAcceptor"/>
</property>
<property name="bindings">
<list>
<bean class="org.apache.mina.integration.spring.Binding">
<property name="address" value=":2577"/>
<property name="handler" ref="smppHandler"/>
<property name="serviceConfig" ref="smppSocketAcceptorConfig"/>
</bean>
</list>
</property>
</bean>
****Client side****
<bean id="smscFilterThreadPoolFactory"
class="org.apache.mina.integration.spring.ThreadPoolExecutorFactoryBean">
<property name="corePoolSize" value="10"/>
<property name="maxPoolSize" value="10"/>
<property name="keepAliveSeconds" value="30"/>
</bean>
<bean id="smscFilterChainBuilder"
class="
org.apache.mina.integration.spring.DefaultIoFilterChainBuilderFactoryBean
">
<property name="filters">
<list>
<bean class="org.apache.mina.filter.executor.ExecutorFilter">
<constructor-arg>
<ref bean="smscFilterThreadPoolFactory"/>
</constructor-arg>
</bean>
<!-- <bean class="org.apache.mina.filter.codec.ProtocolCodecFilter
">
<constructor-arg ref="smppProtocolCodecFactory"/>
</bean> -->
<bean class="org.apache.mina.filter.LoggingFilter"/>
</list>
</property>
</bean>
<bean id="smscSocketConnectorConfig"
class="org.apache.mina.transport.socket.nio.SocketConnectorConfig
">
<property name="filterChainBuilder" ref="smscFilterChainBuilder"/>
<property name="threadModel"
ref="org.apache.mina.common.ThreadModel.MANUAL"/>
</bean>
The smscSocketConnectorConfig is injected into one of our beans.
The client code is similar to
/SocketConnector connector = new SocketConnector();
ConnectFuture future = connector.connect( new InetSocketAddress( ip,
port, clientSession, smscSocketConnectorConfig ));
/
If I comment the protocol codec filter in smscFilterChainBuilder, it is
happy and it even picks up an instance of protocol codec filter (I don't
know how) and messageReceived events are properly generated.
Does the protocol codec filter in server side filter chain has any
effect on the client side filter chain?
No. I suppose your client and server use separate spring config files ?
Not that it is necessary, but it is less confusing :-)
How is my client side filter chain picking up protocol codec filter?
No idea. Are you sure you are not setting up a ProtocolCodecFilter via java
code as well as via spring config ?
Could you show us the exact code used by your client.
Maarten
Thanks
Raju
Maarten Bosteels wrote:
> Raju,
>
> You are probably adding the ProtocolCodecFilter to the filterChain of
the
> SocketAcceptor and
> to the filterChain of the SocketAcceptorConfig.
>
> Does your code look like this:
>
> acceptor.getFilterChain().
> addLast("protocol", new ProtocolCodecFilter(codecFactory)));
>
> acceptor.getDefaultConfig().getFilterChain().addLast(
> "protocol", new ProtocolCodecFilter(codecFactory));
>
>
> When a new connection is accepted, MINA will build a new FilterChain
> for the
> new IoSession.
> It will add all filters of SocketAcceptor.getFilterChain() and of
> SocketAcceptorConfig.getFilterChain() to the filter chain of the
> IoSession.
>
> But obviuosly, a filter chain can contain only one ProtocolCodecFilter.
>
> So I suggest you remove one of the two ProtocolCodecFilter's
>
> HTH
> Maarten
>
> On 5/29/07, Raju Mohanapu <[EMAIL PROTECTED]> wrote:
>>
>> Hello,
>> Our application uses MINA (1.1.0) on both the client and server
>> interfaces. When I try to insert an instance of ProtocolCodecFilter in
>> each of the Configs (Acceptor and Connector configs), it throws an
>> exception with the message - "A filter chain cannot contain more than
>> one ProtocolCodecFilter.".
>> The error is thrown from onPreAdd method of ProtocolCodecFilter class.
>>
>> Do I need to supply the protocol codec filter to one of the configs?
>> either connector or acceptor config? How does the codec filter setting
>> in one config affect the other?
>>
>> Thank you for your time
>>
>> regards
>> Raju
>>
>