View Source OffBroadwayPgmq (OffBroadwayPgmq v0.2.1)

Pgmq producer for broadway, adapted from BroadwaySQS

The producer receives 4 options:

  • :repo: the ecto repo to be used, mandatory.
  • :dynamic_repo: dynamic repo to be used, optional.
  • :queue: the queue name to be used, mandatory.
  • :visibility_timeout: the time the messages will be unavailable in the queue after being read. Required
  • :max_poll_seconds: how long the maximum poll request takes, optional, defaults to 5 seconds.
  • :attempt_interval_ms: interval in ms to wait before doing poll requests in case there is demand but no messages are found. Optional, defaults to 500
  • :pgmq_poll_interval_ms: option on pgmq side that dictates poll interval postgres-side. Optional, defaults to 250.

If you're using many queues, this can be a bit heavy in your connection pool, so its important to configure properly. You might want to adjust max_poll_seconds and :attempt_interval_ms to trade off connection usage for more latency. You can also use a :max_poll_seconds of 0 to perform no polling at all.

:pgmq_poll_interval_ms is the database side poll interval. By adjusting it, you can increase or decrease the amount of work performed database side at the risk of getting more latency.