I guess the answer to this question depends on what Restlet framework has
built in to do that.
I just looked at the code for Restlet, and it appears to use an unbounded
ConcurrentLinkedQueue to handle incoming requests. I didn't see anything
obvious for how to throttle the requests: however, I bet it's extensible in
some way for you to write in a custom handler/throttler... though that
might be a good question for the Restlet community.

I think if you used the Throttler in Camel, it would at least slow down the
work that the Restlet threads can do (and maybe even give back 503...),
though you'd have to try it out yourself to see how much it would throttle.

You may wish to take a look at a different (jetty? or cxf-rs?) component
that depends on a container where you might be able to more easily control
that backlog of requests over the http connectors.


On Tue, Aug 27, 2013 at 6:55 PM, osupit <ollie.su...@gmail.com> wrote:

> Hi
>
> I have a set of routes that looks like this:
>
> --------------------------------------------
>
>                 <route id="getcustomer">
>                         <from
> uri="restlet:http://
> {{fpRestHost}}:{{fpRestPort}}/greenfield/customer/getcustomer/{customerId}?restletMethod=GET"
> />
>                         <to
> uri="bean:customCustomerService?method=getCustomer"/>
>                 </route>
>
> --------------------------------------------
>
> In my bean "customCustomerService" I call a backend service that needs to
> be
> protected as it falls over under load.
>
> The requirement is that excess incoming requests need to be discarded
> (returned an appropriate a HTTP status code eg  503 unavailable
> immediately).
>
> So for example if only 10 requests can be processed concurrently, any
> (HTTP)
> requests that come in while those ten slots are being processed  need
> return
> to immediately to the caller.
>
> I've looked at the Throttler EIP and the ThrottlingInflightRoutePolicy
> routepolicy but these seem to just block/wait or queue excess requests to
> be
> serviced when the protected resource is ready again.
>
> Is there an alternative throttling technique which allows me to discard
> requests as described above?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/throttling-a-restlet-endpoint-by-discarding-excess-requests-tp5738089.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Reply via email to