0
votes

I am using Apache camel and jboss fuse, I have created a sample route blue print listed below in, i have sucessfully handling exceptions in all my routes now the problem is i can not find any example of throttling in routes as i have defined. in apache camel documentation, they have given simple DSL throttling and in stackoverflow i have found rabbitMq throttling which is not my case. how to throttle routes like this in apache camel

<?xml version="1.0" encoding="UTF-8"?>
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
        xmlns:camel="http://camel.apache.org/schema/blueprint"
        xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd        http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
        <cxf:rsServer address="/testservice" id="testserver" serviceClass="com.company.HelloBean">
        <camelContext id="testContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
            <route id="testRoute" >
              <throttle timePeriodMillis="10000">
                <constant>3</constant>
                <from id="_from1" uri="cxfrs:bean:testserver"/>
                    <bean beanType="com.company.HelloBean"
                        id="_bean1" method="hello"/>
              </throttle>
            </route>
        </camelContext>
    </blueprint>

this give error when in deploy application in jboss fuse. that can not find service

1
you don't throttle the bean. You throttle the routepvpkiran

1 Answers

2
votes

hy, all you need is you are currently defining your from endpoint in throttle tag which is wrong you need to define the throttling tag only in TO tag like this

  <throttle id="_throttle1" rejectExecution="true" timePeriodMillis="10000">
                <constant>1</constant>
                <bean beanType="com.company.HelloBean"
                    id="_bean1" method="hello"/>
            </throttle>

when requests come to an end point from, you will throttle while requests are going TO another end point you are using beans so, you can do something like this

    <?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:camel="http://camel.apache.org/schema/blueprint"
    xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd        http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
    <cxf:rsServer address="/testservice" id="testserver" serviceClass="com.evampsaanga.gethomepage.GetHomePageDataLand">
        <cxf:providers>
            <bean class="com.evampsaanga.restresponses.ExceptionHandler" id="securityException"/>
        </cxf:providers>
    </cxf:rsServer>
<!--     <bean class="com.saanga.servicetest.THR" id="myPolicy"/> -->
    <camelContext id="testContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
        <route id="testRoute" >
            <from id="_from1" uri="cxfrs:bean:testserver"/>
            <log id="_log1" message="header : ${headers}"/>
            <setHeader headerName="headerbalance" id="_setHeader1">
                <simple>${headers}</simple>
            </setHeader>
            <setBody id="_setBody1">
                <simple>${body}</simple>
            </setBody>
            <throttle id="_throttle1" rejectExecution="true" timePeriodMillis="10000">
                <constant>1</constant>
                <bean beanType="com.evampsaanga.gethomepage.GetHomePageDataLand"
                    id="_bean1" method="Get"/>
            </throttle>
        </route>
    </camelContext>
</blueprint>