Reference

Configuration reference

Every Pgbus.configure option, grouped by concern.

Reading this page#

Set any of these in a Pgbus.configure block. Durations accept an integer number of seconds or an ActiveSupport::Duration. Every option has a default, so you only set what you need. For the knobs most apps touch first, start with Configuration.

Connection#

OptionTypeDefaultDescription
database_urlString, nilnilPostgreSQL URL (auto-detected in Rails).
connection_paramsHash, nilnilExtra connection parameters merged into the pool.
pool_sizeInteger, nilnil (auto)Connection pool size; auto-tuned from thread counts when nil.
pool_timeoutNumeric5Seconds to wait for a pooled connection.
connects_toHash, nilnilRails multi-database config for a dedicated pgbus database.
require_primaryBooleanfalseReject a job connection that lands on a read-only replica (pg_is_in_recovery) at boot — pooler safety against a read/write splitter routing pgmq reads to a standby.
connection_guc_modeSymbol:optionsHow database.yml GUCs (variables:) reach pgmq connections — :options (libpq startup param) or :session (post-connect SET, for a transaction-mode PgBouncer that rejects the options param).

Queues#

OptionTypeDefaultDescription
queue_prefixString"pgbus"Prefix for every PGMQ queue name.
default_queueString"default"Queue for jobs without an explicit queue.
priority_levelsInteger, nilnilNumber of priority sub-queues (2–10); nil disables.
default_priorityInteger1Priority for jobs without an explicit one.
group_modeSymbol, nilnilGrouped-read ordering mode for a queue. Experimental — exempt from the 1.0 stability promise.

Workers#

OptionTypeDefaultDescription
workersString / Arraydefault: 5Worker capsule definitions (string DSL or array).
event_consumersString / Array, nilnilEvent-consumer process definitions.
rolesArray, nilnil (all)Supervisor role filter — usually set via CLI flags.
execution_modeSymbol:threadsGlobal execution mode (:threads or :async).
polling_intervalNumeric0.1Seconds between polls (LISTEN/NOTIFY is primary).
prefetch_limitInteger, nilnilMax in-flight messages per worker.
visibility_timeoutDuration30How long a read message stays invisible before retry.

Worker recycling#

OptionTypeDefaultDescription
max_jobs_per_workerInteger, nilnilRecycle a worker after N jobs.
max_memory_mbInteger, nilnilRecycle a worker above N MB RSS.
max_worker_lifetimeDuration, nilnilRecycle a worker after N seconds.

Retries & reliability#

OptionTypeDefaultDescription
max_retriesInteger5Failed reads before routing to the dead-letter queue.
retry_backoffNumeric5Base delay (seconds) for exponential retry backoff.
retry_backoff_maxNumeric300Cap on the retry delay.
retry_backoff_jitterFloat0.15Jitter factor (0–1) added to retry delays.
circuit_breaker_enabledBooleantrueAuto-pause a queue after consecutive failures.
listen_notifyBooleantrueUse PGMQ LISTEN/NOTIFY for instant wake-up.
zombie_detectionBooleantrueDetect and reclaim work from crashed workers.

Dispatcher & maintenance#

OptionTypeDefaultDescription
dispatch_intervalNumeric1.0Seconds between dispatcher maintenance ticks.
archive_retentionDuration, nil7.daysHow long to keep archived messages; nil disables cleanup.
idempotency_ttlDuration, nil7.daysHow long processed-event records are kept for dedup.

Outbox#

OptionTypeDefaultDescription
outbox_enabledBooleanfalseEnable the transactional outbox poller.
outbox_poll_intervalNumeric1.0Seconds between outbox poll cycles.
outbox_batch_sizeInteger100Max entries claimed per outbox cycle.
outbox_retentionDuration, nil1.dayHow long to keep published outbox entries.

Recurring tasks#

OptionTypeDefaultDescription
recurring_tasksHash, nilnilRecurring task definitions as a hash.
recurring_tasks_filesArray, nilnilPaths to recurring.yml files. Replaces the deprecated singular recurring_tasks_file.
recurring_schedule_intervalNumeric1.0Seconds between scheduler ticks.
recurring_execution_retentionDuration, nil7.daysHow long to keep recurring execution history.
recurring_enabledBooleantrueRun the recurring scheduler (set false to disable it entirely). Replaces the deprecated skip_recurring.

Job stats#

OptionTypeDefaultDescription
stats_enabledBooleantrueRecord job execution stats for insights.
stats_retentionDuration, nil30.daysHow long to keep job stats.
stats_flush_sizeInteger100Buffered stats per worker before a bulk insert.
stats_flush_intervalNumeric5Seconds between periodic stat flushes.

Dashboard#

OptionTypeDefaultDescription
web_authCallable, nilnilLambda authorizing dashboard access.
base_controller_classString"::ActionController::Base"Base class for dashboard controllers.
return_to_app_urlString, nilnilURL for the "back to app" button.
web_refresh_intervalInteger5000Dashboard auto-refresh interval (ms).
web_live_updatesBooleantrueEnable Turbo Frames auto-refresh.
web_per_pageInteger25Dashboard pagination size.
web_filter_sensitiveBooleantrueRedact sensitive values in dashboard payload views. Replaces the deprecated dashboard_filter_sensitive.
web_filter_parametersArray, nilnil (auto)Parameter-name patterns to redact; nil auto-detects from Rails. Replaces the deprecated dashboard_filter_parameters.
metrics_enabledBooleantrueExpose Prometheus gauges on the dashboard.

Metrics & logging#

OptionTypeDefaultDescription
metrics_backendSymbol, Object, nilnilMetrics adapter: nil, :prometheus, :statsd, or a Backend.
statsd_hostString"127.0.0.1"StatsD UDP host.
statsd_portInteger8125StatsD UDP port.
log_formatSymbol:textLog formatter (:text or :json).
error_reportersArray[]Callables invoked on caught exceptions.
appsignal_enabledBooleantrueEnable the AppSignal subscriber + probe (when the gem is present).
appsignal_probe_enabledBooleantrueEnable the minutely AppSignal gauge probe.

Health & liveness#

OptionTypeDefaultDescription
health_portInteger, nilnilPort for HTTP liveness/readiness probes; nil disables.
health_bindString"127.0.0.1"Bind address for the health server.
stall_thresholdNumeric300Seconds without progress before a worker is stalled.
read_timeoutNumeric30Read timeout for worker fetches.
drain_timeoutNumeric30Seconds to wait for in-flight jobs to finish during graceful shutdown before abandoning them.

Streams (SSE)#

OptionTypeDefaultDescription
streams_enabledBooleantrueEnable the SSE streams transport.
streams_queue_prefixString"pgbus_stream"Prefix for stream queues.
streams_default_retentionNumeric300Default stream retention in seconds.
streams_retentionHash{}Per-stream retention overrides.
streams_heartbeat_intervalNumeric15SSE heartbeat interval (seconds).
streams_max_connectionsInteger2000Max SSE connections per web-server process.
streams_idle_timeoutNumeric3600Close idle SSE connections after N seconds.
streams_pool_sizeInteger5Dedicated DB pool for durable-stream publish + replay, isolated from the job pool so a saturated worker pool can't delay broadcasts. Ignored on the shared-ActiveRecord connection path.
streams_pool_timeoutNumeric5Seconds to wait for a connection from the dedicated streams pool.
streams_pool_autoscaleBooleanfalseSelf-tuning: a periodic maintenance check (on the streamer's idle LISTEN connection — no extra connection) grows the streams pool into a fair share of live Postgres connection headroom under saturation, shrinks back to streams_pool_size when idle, and emergency-shrinks if the DB runs low on connections. Opt-in; no-op on the shared-ActiveRecord path.
streams_pool_maxInteger, nilnilOptional hard ceiling for streams-pool autoscaling. nil lets the dynamic per-process fair share of DB headroom be the effective cap.
streams_pathString, nilnilCustom SSE endpoint path (auto-detected from mount).
streams_falcon_streaming_bodyBooleanfalseUse Falcon-native streaming body instead of hijack. Experimental — exempt from the 1.0 stability promise.
streams_stats_enabledBooleanfalseRecord stream broadcast/connect/disconnect stats.
streams_test_modeBooleanfalseReturn a stub SSE response (auto-enabled by the test helpers).
streams_presence_patternsArray[]Streams (exact string or Regexp) that get connection-driven presence: auto-join on connect, auto-leave on disconnect, heartbeat touch. Experimental — exempt from the 1.0 stability promise.
streams_presence_memberCallable, nilnilCustom `->(context) { { id:, metadata: } }` extractor for connection-driven presence; nil uses the built-in Hash/#id extractor. Experimental — exempt from the 1.0 stability promise.
streams_broadcast_queueString, nilnilDedicated queue for turbo-rails' async broadcast jobs. nil leaves them on the default queue (a broadcasts_to render+broadcast can wait behind long-running jobs). Set a queue name and back it with a worker capsule to isolate broadcast latency.

Validation#

OptionTypeDefaultDescription
eager_validationBooleantrueValidate configuration eagerly at boot.
allowed_global_id_modelsArray, nilnilAllowlist of models permitted as GlobalID event arguments.
pgmq_schema_modeSymbol:autoPGMQ schema install mode (:auto, :extension, :embedded).