I've been using a different kind of sampling based throttling pattern recently and figured others might find it useful. The basic premise is the same as the current throttler, there is a consumer downstream that has specific requirements as to how fast it can process incoming exchanges and a mechanism is required to 'throttle' the exchanges inbound to it. The difference between the current throttler implementation and the sampling throttler is that where the current throttler queues up all the exchanges it receives, the sampling throttler will allow only a single exchange through for a period and 'drop' all others; dropped exchanges being passed to a stop processor to complete them.
Its been useful for situations where a route receives many semantically equivalent exchanges in a time period, any single one of which could be used to represent them all. For example, say an upstream component generates a stream of warning alarms and sends these to an email processor to inform the operator. An email for each alarm would be overkill instead one every x minutes or so would be preferred. Also it would be undesirable for the throttler to queue up these warning alarms as when the upstream component ceases sending them the emails should cease. Sampling the warnings would pick one for each x minute period, and stop the rest.
This would be defined via the java dsl as follows
or with a default of one per second
In spring xml it looks like
If this patch is accepted, I'd be happy to update the wiki with the required documentation. As per ususal I've split the patches, one for core and one for spring