The Throttle Mediator can be used for rate-limiting as well as concurrency-based limiting. A WS-Policy dictates the throttling configuration and may be specified inline or loaded from the registry. The Throttle Mediator could be added in the request path for rate limiting and concurrent access limitation. When using for concurrent access limitation, the same Throttle Mediator
id must be triggered on the response flow so that completed responses are deducted from the available limit. (i.e. two instances of the throttle mediator with the same
id attribute in the request and response flows). The
onAccept sequence references or inline sequences define how accepted and rejected messages are to be handled.
The Throttle mediator carries out throttling for a proxy service at the stage where requests are being mediated. If you want the throttling to be carried out before mediation, define a throttle policy at service level.
Throttle Mediator Options:
Throttle Group ID - The id for the throttle group.
You would have to throttle mediator configuration in request and response paths with the same group id.
- Throttle Referring Policy - The policy for the throttling. You can specify it inline or refer from Configuration Registry or Governance Registry.
- On Acceptance Referring Sequence - The sequence to act on acceptance. You can specify it inline or refer from Configuration Registry or Governance Registry.
- On Rejection Referring Sequence - The sequence to act on rejection. You can specify it inline or refer from Configuration Registry or Governance Registry.
For more information on the registry, see Working with the Registry.
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.
The above example specifies the Throttle Mediator inside the In Mediator. Therefore, all request messages directed to the main sequence will be subjected to throttling. The Throttle Mediator has
onReject tags at top level. The
policy tag specifies the throttling policy for throttling messages. This sample policy only contains a component called
MaximumConcurrentAccess. This indicates the maximum number of concurrent requests that can pass through Synapse on a single unit of time.