camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aka...@apache.org
Subject svn commit: r1064901 - in /camel/trunk: ./ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/mbean/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/spi/ compo...
Date Fri, 28 Jan 2011 21:43:26 GMT
Author: akarpe
Date: Fri Jan 28 21:43:25 2011
New Revision: 1064901

URL: http://svn.apache.org/viewvc?rev=1064901&view=rev
Log:
CAMEL-3254 Added ability to set multiple policies on a route in Spring
and via API's

Added:
    camel/trunk/.DS_Store
    camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java
    camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java
    camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/routepolicy/quartz/MultiplePolicies.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java
    camel/trunk/components/camel-quartz/pom.xml
    camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java
    camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringScheduledRoutePolicyTest.java

Added: camel/trunk/.DS_Store
URL: http://svn.apache.org/viewvc/camel/trunk/.DS_Store?rev=1064901&view=auto
==============================================================================
Files camel/trunk/.DS_Store (added) and camel/trunk/.DS_Store Fri Jan 28 21:43:25 2011 differ

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java?rev=1064901&r1=1064900&r2=1064901&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java Fri
Jan 28 21:43:25 2011
@@ -63,7 +63,7 @@ public class DefaultRouteContext impleme
     private Boolean handleFault;
     private Long delay;
     private Boolean autoStartup = Boolean.TRUE;
-    private RoutePolicy routePolicy;
+    private List<RoutePolicy> routePolicyList = new ArrayList<RoutePolicy>();
     private ShutdownRoute shutdownRoute;
     private ShutdownRunningTask shutdownRunningTask;
 
@@ -154,15 +154,24 @@ public class DefaultRouteContext impleme
 
             // and then optionally add route policy processor if a custom policy is set
             RoutePolicyProcessor routePolicyProcessor = null;
-            RoutePolicy policy = getRoutePolicy();
-            if (policy != null) {
-                routePolicyProcessor = new RoutePolicyProcessor(unitOfWorkProcessor, policy);
-                // add it as service if we have not already done that (eg possible if two
routes have the same service)
-                if (!camelContext.hasService(policy)) {
-                    try {
-                        camelContext.addService(policy);
-                    } catch (Exception e) {
-                        throw ObjectHelper.wrapRuntimeCamelException(e);
+            List<RoutePolicy> policyList = getRoutePolicyList();
+            if (!policyList.isEmpty()) {
+                boolean firstPolicy = true;
+                for (RoutePolicy policy : policyList) {
+                    if (firstPolicy) {
+                        routePolicyProcessor = new RoutePolicyProcessor(unitOfWorkProcessor,
policy);
+                        firstPolicy = false;
+                    } else {
+                        routePolicyProcessor = new RoutePolicyProcessor(routePolicyProcessor,
policy);
+                    }
+                    
+                    // add it as service if we have not already done that (eg possible if
two routes have the same service)
+                    if (!camelContext.hasService(policy)) {
+                        try {
+                            camelContext.addService(policy);
+                        } catch (Exception e) {
+                            throw ObjectHelper.wrapRuntimeCamelException(e);
+                        }
                     }
                 }
                 target = routePolicyProcessor;
@@ -190,8 +199,10 @@ public class DefaultRouteContext impleme
             }
 
             // invoke init on route policy
-            if (policy != null) {
-                policy.onInit(edcr);
+            if (!policyList.isEmpty()) {
+                for (RoutePolicy policy : policyList) { 
+                    policy.onInit(edcr);
+                }
             }
 
             routes.add(edcr);
@@ -319,15 +330,7 @@ public class DefaultRouteContext impleme
             return getCamelContext().getShutdownRunningTask();
         }
     }
-
-    public RoutePolicy getRoutePolicy() {
-        return routePolicy;
-    }
-
-    public void setRoutePolicy(RoutePolicy routePolicy) {
-        this.routePolicy = routePolicy;
-    }
-
+    
     public int getAndIncrement(ProcessorDefinition<?> node) {
         AtomicInteger count = nodeIndex.get(node);
         if (count == null) {
@@ -336,4 +339,12 @@ public class DefaultRouteContext impleme
         }
         return count.getAndIncrement();
     }
+
+    public void setRoutePolicyList(List<RoutePolicy> routePolicyList) {
+        this.routePolicyList = routePolicyList;
+    }
+
+    public List<RoutePolicy> getRoutePolicyList() {
+        return routePolicyList;
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java?rev=1064901&r1=1064900&r2=1064901&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedRoute.java
Fri Jan 28 21:43:25 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.management.mbean;
 
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
@@ -107,13 +108,17 @@ public class ManagedRoute extends Manage
         route.getRouteContext().setTracing(tracing);
     }
 
-    @ManagedAttribute(description = "Route Policy")
-    public String getRoutePolicy() {
-        RoutePolicy policy = route.getRouteContext().getRoutePolicy();
-        if (policy != null) {
+    @ManagedAttribute(description = "Route Policy List")
+    public String getRoutePolicyList() {
+        List<RoutePolicy> policyList = route.getRouteContext().getRoutePolicyList();
+        if (policyList != null) {
             StringBuilder sb = new StringBuilder();
-            sb.append(policy.getClass().getSimpleName());
-            sb.append("(").append(ObjectHelper.getIdentityHashCode(policy)).append(")");
+            for (RoutePolicy policy : policyList) {
+                sb.append(policy.getClass().getSimpleName());
+                sb.append("(").append(ObjectHelper.getIdentityHashCode(policy)).append(")");
+                sb.append(", ");
+            }
+            sb = sb.delete(sb.lastIndexOf(", "), sb.length() - 1);
             return sb.toString();
         }
         return null;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java?rev=1064901&r1=1064900&r2=1064901&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinition.java Fri Jan
28 21:43:25 2011
@@ -19,6 +19,7 @@ package org.apache.camel.model;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.StringTokenizer;
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -699,13 +700,16 @@ public class RouteDefinition extends Pro
             if (log.isDebugEnabled()) {
                 log.debug("RoutePolicy is enabled: " + routePolicy + " on route: " + this);
             }
-            routeContext.setRoutePolicy(getRoutePolicy());
+            routeContext.getRoutePolicyList().add(getRoutePolicy());
         } else if (routePolicyRef != null) {
-            RoutePolicy policy = CamelContextHelper.mandatoryLookup(camelContext, routePolicyRef,
RoutePolicy.class);
-            if (log.isDebugEnabled()) {
-                log.debug("RoutePolicy is enabled: " + policy + " on route: " + this);
+            StringTokenizer policyTokens = new StringTokenizer(routePolicyRef, ",");
+            while (policyTokens.hasMoreTokens()) {
+                RoutePolicy policy = CamelContextHelper.mandatoryLookup(camelContext, policyTokens.nextToken().trim(),
RoutePolicy.class);
+                if (log.isDebugEnabled()) {
+                    log.debug("RoutePolicy is enabled: " + policy + " on route: " + this);
+                }
+                routeContext.getRoutePolicyList().add(policy);
             }
-            routeContext.setRoutePolicy(policy);
         }
 
         // configure auto startup

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java?rev=1064901&r1=1064900&r2=1064901&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java Fri Jan 28
21:43:25 2011
@@ -173,18 +173,18 @@ public interface RouteContext extends Ru
     boolean isRouteAdded();
     
     /**
-     * Gets the route policy
+     * Gets the route policy List
      *
-     * @return the route policy if any
+     * @return the route policy list if any
      */
-    RoutePolicy getRoutePolicy();
+    List<RoutePolicy> getRoutePolicyList();
 
     /**
-     * Sets a custom route policy
+     * Sets a custom route policy List
      *
-     * @param routePolicy the custom route policy
+     * @param routePolicyList the custom route policy list
      */
-    void setRoutePolicy(RoutePolicy routePolicy);
+    void setRoutePolicyList(List<RoutePolicy> routePolicyList);
 
     /**
      * A private counter that increments, is used to as book keeping

Modified: camel/trunk/components/camel-quartz/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/pom.xml?rev=1064901&r1=1064900&r2=1064901&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/pom.xml (original)
+++ camel/trunk/components/camel-quartz/pom.xml Fri Jan 28 21:43:25 2011
@@ -73,6 +73,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core-xml</artifactId>            
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
             <artifactId>camel-test</artifactId>            
             <scope>test</scope>
         </dependency>

Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java?rev=1064901&r1=1064900&r2=1064901&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java
(original)
+++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/routepolicy/quartz/ScheduledJob.java
Fri Jan 28 21:43:25 2011
@@ -17,8 +17,10 @@
 package org.apache.camel.routepolicy.quartz;
 
 import java.io.Serializable;
+import java.util.List;
 
 import org.apache.camel.Route;
+import org.apache.camel.spi.RoutePolicy;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -45,11 +47,15 @@ public class ScheduledJob implements Job
         Action storedAction = state.getAction(); 
         storedRoute = state.getRoute();
         
-        ScheduledRoutePolicy policy = (ScheduledRoutePolicy) storedRoute.getRouteContext().getRoutePolicy();
-        try {
-            policy.onJobExecute(storedAction, storedRoute);
-        } catch (Exception e) {
-            throw new JobExecutionException("Failed to execute Scheduled Job for route "
+ storedRoute.getId() + " with trigger name: " + jobExecutionContext.getTrigger().getFullName());
+        List<RoutePolicy> policyList = storedRoute.getRouteContext().getRoutePolicyList();
+        for (RoutePolicy policy : policyList) {
+            try {
+                if (policy instanceof ScheduledRoutePolicy) {
+                    ((ScheduledRoutePolicy)policy).onJobExecute(storedAction, storedRoute);
+                }
+            } catch (Exception e) {
+                throw new JobExecutionException("Failed to execute Scheduled Job for route
" + storedRoute.getId() + " with trigger name: " + jobExecutionContext.getTrigger().getFullName());
+            }
         }
     }
 

Added: camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java?rev=1064901&view=auto
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java
(added)
+++ camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/MultiplePoliciesOnRouteTest.java
Fri Jan 28 21:43:25 2011
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.routepolicy.quartz;
+
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.ThrottlingInflightRoutePolicy;
+import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ServiceHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+
+/**
+ * @version $Revision: 882486 $
+ */
+public class MultiplePoliciesOnRouteTest extends CamelTestSupport {
+    private static final transient Log LOG = LogFactory.getLog(MultiplePoliciesOnRouteTest.class);
+    private String url = "seda:foo?concurrentConsumers=20";
+    private int size = 100;
+    
+    /* (non-Javadoc)
+     * @see org.apache.camel.test.junit4.CamelTestSupport#s;etUp()
+     */
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = new JndiRegistry(createJndiContext());
+        registry.bind("startPolicy", createRouteStartPolicy());
+        registry.bind("throttlePolicy", createThrottlePolicy());
+        return registry;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.camel.test.junit4.CamelTestSupport#isUseRouteBuilder()
+     */
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    private RoutePolicy createRouteStartPolicy() {
+        SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+        long startTime = System.currentTimeMillis() + 3000L;
+        policy.setRouteStartDate(new Date(startTime));
+        policy.setRouteStartRepeatCount(1);
+        policy.setRouteStartRepeatInterval(3000);
+        
+        return policy;
+    }
+    
+    private RoutePolicy createThrottlePolicy() {
+        ThrottlingInflightRoutePolicy policy = new ThrottlingInflightRoutePolicy();
+        policy.setMaxInflightExchanges(10);
+        return policy;
+    }
+    
+    @Test
+    public void testMultiplePoliciesOnRoute() throws Exception {
+        MockEndpoint success = (MockEndpoint) context.getEndpoint("mock:success");      
 
+        
+        success.expectedMinimumMessageCount(size - 10);
+        
+        context.getComponent("quartz", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz/myquartz.properties");
+        context.getComponent("quartz", QuartzComponent.class).start();
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {   
+                from(url)
+                    .routeId("test")
+                    .routePolicyRef("startPolicy, throttlePolicy")
+                    .to("log:foo?groupSize=10")
+                    .to("mock:success");
+            }
+        });
+        context.start();
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
+        for (int i = 0; i < size; i++) {
+            template.sendBody(url, "Message " + i);
+            Thread.sleep(3);
+        }
+
+        context.getComponent("quartz", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+
+}

Added: camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java?rev=1064901&view=auto
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java
(added)
+++ camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringMultiplePoliciesOnRouteTest.java
Fri Jan 28 21:43:25 2011
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.routepolicy.quartz;
+
+import org.apache.camel.test.CamelSpringTestSupport;
+import org.apache.camel.test.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringMultiplePoliciesOnRouteTest extends CamelSpringTestSupport {
+    private String url = "seda:foo?concurrentConsumers=20";
+    private int size = 100;
+
+    @Test
+    public void testMultiplePoliciesOnRoute() throws Exception {
+        // we use seda which are not persistent and hence can loose a message
+        // when we get graceful shutdown support we can prevent this
+        getMockEndpoint("mock:success").expectedMinimumMessageCount(size - 10);
+
+        for (int i = 0; i < size; i++) {
+            template.sendBody(url, "Message " + i);
+            Thread.sleep(3);
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.test.CamelSpringTestSupport#createApplicationContext()
+     */
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        // TODO Auto-generated method stub
+        return new ClassPathXmlApplicationContext("org/apache/camel/routepolicy/quartz/MultiplePolicies.xml");
+    }
+    
+}

Modified: camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringScheduledRoutePolicyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringScheduledRoutePolicyTest.java?rev=1064901&r1=1064900&r2=1064901&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringScheduledRoutePolicyTest.java
(original)
+++ camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/routepolicy/quartz/SpringScheduledRoutePolicyTest.java
Fri Jan 28 21:43:25 2011
@@ -117,7 +117,7 @@ public abstract class SpringScheduledRou
         context.start();
         return context;
     }
-
+    
     public ClassPathXmlApplicationContext getApplicationContext() {
         return applicationContext;
     }

Added: camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/routepolicy/quartz/MultiplePolicies.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/routepolicy/quartz/MultiplePolicies.xml?rev=1064901&view=auto
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/routepolicy/quartz/MultiplePolicies.xml
(added)
+++ camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/routepolicy/quartz/MultiplePolicies.xml
Fri Jan 28 21:43:25 2011
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="date" class="org.apache.camel.routepolicy.quartz.SimpleDate"/>
+
+    <bean id="startPolicy" class="org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy">
+    	<property name="routeStartDate" ref="date"/>
+    	<property name="routeStartRepeatCount" value="1"/>
+    	<property name="routeStartRepeatInterval" value="3000"/>    	
+    </bean>
+    
+    <bean id="throttlePolicy" class="org.apache.camel.impl.ThrottlingInflightRoutePolicy">
+    	<property name="maxInflightExchanges" value="10"/>    	
+	</bean>
+	 	
+    <camelContext id="testRouteContext" xmlns="http://camel.apache.org/schema/spring">
+        <route id="testRoute" autoStartup="false" routePolicyRef="startPolicy, throttlePolicy">
+            <from uri="seda:foo?concurrentConsumers=20"/>
+            <to uri="mock:success"/>
+        </route>
+    </camelContext>
+
+</beans>



Mime
View raw message