-2

I have been reading the Jersey 2.17 user guide for possibities around applying governance limits on the exposed RESTLet resources. I am particularly interested in applying limits on incoming requests for a particular Jersey RESTLet resource for a particular client consumer (For example: I want to only allow 10 requests per 30 second from any particular source).

Please let me know if anybody has a feasible approach in mind based on their experience with the native API capabilities. Thanks in advance!

1 Answers1

1

What you can do to achieve this with Restlet is to use the APISpark extension.

This similar question should answer your question: Limit request on a Restlet resource with APISpark restlet extension

Where you can do something like this:

FirewallRule rule = new PeriodicFirewallCounterRule(60, TimeUnit.SECONDS, new IpAddressCountingPolicy());
((PeriodicFirewallCounterRule)rule).addHandler(new RateLimitationHandler(new UniqueLimitPolicy(10)));
FirewallFilter firewallFiler = new FirewallFilter(getContext(), list(rule));
firewallFiler.setNext(router);

To limit the access to your app's Restlet server resources. I hope this helps or at least give you a hint.

Community
  • 1
  • 1
quarks
  • 33,478
  • 73
  • 290
  • 513
  • I am not using the Restlet framework, will APISpark work with Jersey? – javablinders Mar 23 '15 at 11:37
  • @javablinders You tagged your question with 'restlet' so I thought you were using Restlet framework. Anyway I suggest you try Restlet Framework than Jersey, after all Restlet has its Jersey implementation – quarks Mar 23 '15 at 14:02