Share on Google+Share on Google+

Spring AOP concurency Throttle Interceptor

In this tutorial you will see how Interceptor throttles concurrent access.

AOP concurrency Throttle Interceptor

In this example you will see, Interceptor that throttles concurrent access, blocking invocations if a specified concurrency limit is reached.


public class StudentBean {
	String studentName;
	String studentCourse;

	public String getStudentName() {
		return studentName;

	public void setStudentName(String studentName) {
		this.studentName = studentName;

	public String getStudentCourse() {
		return studentCourse;

	public void setStudentCourse(String studentCourse) {
		this.studentCourse = studentCourse;

	public void showValue() {
		System.out.println("Show Results:" + this.studentName + " "
				+ this.studentCourse);


import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;

public class MainClaz {
	public static void main(String[] args) {
		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
		StudentBean studentBean = (StudentBean) beanFactory.getBean("testBean");


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="testBean" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target">
      <bean class="">
        <property name="studentName" value="James Bond," />
        <property name="studentCourse" value="B.Tech" />
    <property name="interceptorNames">
        <idref bean="nameMatchMethodPointcutAdvisor" />
    <property name="proxyTargetClass" value="true" />
  <bean id="nameMatchMethodPointcutAdvisor"
    <property name="advice" ref="concurrencyThrottleInterceptor" />
    <property name="mappedName" value="showValue" />
  <bean id="concurrencyThrottleInterceptor"
    <property name="concurrencyLimit" value="1" />


When you run this application it will display message as shown below:

Show Results:James Bond, B.Tech

Download this example code


Posted on: September 15, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null