Skip to content

Version 2.0.0

Choose a tag to compare

@jimlambie jimlambie released this 25 Oct 16:51
· 54 commits to master since this release

Queue Throttling

Queue Version 2.0.0 introduces the ability to control how many messages are processed in a defined timespan. This can be useful if a consumer (worker) uses external APIs which are rate limited, for example.

Queue throttling gives:

  • the ability to set a default rate limit for the queue
  • the ability to set message specific rate limits

This version introduces a breaking change, in that the previous configuration for throttling the number of concurrent workers has been abstracted from broker.throttle to broker.throttle.workers.

See the README for updated configuration documentation.

Here is an example:

"throttle": {
  "workers": 5,
  "queue": {
    "unit": "second",
    "value": 1
  },
  "messages": [
    {
      "name": "ten-per-second",
      "regex": "^tps-.*$",  // messages starting with "tps-"
      "regexOpts": "i",
      "unit": "second",
      "value": 10
    },
    {
      "name": "one-per-minute",
      "regex": "^opm-.*$",  // messages starting with "opm-"
      "regexOpts": "i",
      "unit": "minute",
      "value": 1,
      "discard": true
    }
  ]
}