Development

Using the Spring ConcurrencyThrottleInterceptor

The ConcurrencyThrottleInterceptor is a great bit of stuff to limit your use of heavy weight resources.

Use it simply by creating the bean:

<bean id="global_concurrency" class="org.springframework.aop.interceptor.ConcurrencyThrottleInterceptor" singleton="false">
      <property name="concurrencyLimit" value="5"/>
</bean>

Then weaving an aspect

<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="beanNames">
            <value>SomeThing</value>
        </property>
        <property name="interceptorNames">
            <list>
                <value>global_concurrency</value>
            </list>
        </property>
</bean>

However there is an important thing to note, which may-or-may not be completely obvious… the singleton must be set to false, otherwise you are saying that only a certain number of simultaneous invocations are allowed for all the beans you list, not just for each one individually.

comments powered by Disqus