Skip to content

Commit

Permalink
Add consumer-timeout config option
Browse files Browse the repository at this point in the history
Exposes the consumer timeout configuration value that was changed in the jammy
version of rabbitmq. The value used to default to unlimited, but was changed to
30 minutes. This causes clients to timeout for longer-running jobs.

This change doesn't alter the payload's default value, it override it only when
the user provides a value via juju config.

Closes-Bug: #2020909
Related-Bug: #2067424

Change-Id: I552c04c964c98b2a700cd47e98a2ae491f5fd47b
  • Loading branch information
silverdrake11 committed May 29, 2024
1 parent 87e7c1a commit edf7791
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ options:
internally to the charm if no value is set here. Also, if this value is
left unset and this application is running inside a container, the number
of threads will be capped based on a maximum of 2 cores.
consumer-timeout:
type: int
default:
description: |
Timeout value in milliseconds. If a consumer does not ack its delivery
for more than the timeout value, its channel will be closed. If the value
is not specified and rabbitmq version is 3.9 and above, then 30 minutes is the
default. For 3.8 the default value is unlimited. For before that then this feature
is not supported (timeout is unlimited). (See
https://www.rabbitmq.com/docs/consumers#acknowledgement-timeout for more info).
# SSL configuration
ssl:
type: string
Expand Down
3 changes: 3 additions & 0 deletions hooks/rabbitmq_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ def __call__(self):
if config('connection-backlog'):
ctxt['connection_backlog'] = config('connection-backlog')

if config('consumer-timeout'):
ctxt['consumer_timeout'] = config('consumer-timeout')

if cmp_pkgrevno('rabbitmq-server', '3.6') >= 0:
ctxt['queue_master_locator'] = config('queue-master-locator')

Expand Down
4 changes: 4 additions & 0 deletions templates/rabbitmq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ listeners.tcp = none
tcp_listen_options.backlog = {{connection_backlog}}
{%- endif %}

{%- if consumer_timeout %}
consumer_timeout = {{consumer_timeout}}
{%- endif %}

{%- if ssl_port %}
listeners.ssl.1 = {{ ssl_port }}
{%- endif %}
Expand Down
2 changes: 2 additions & 0 deletions unit_tests/test_rabbitmq_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def test_context_ssl_off(self, config, mock_cmp_pkgrevno, mock_leader_get):
mock_leader_get.return_value = 'ignore'
config_data = {'cluster-partition-handling': 'ignore',
'connection-backlog': 200,
'consumer-timeout': 20000,
'mnesia-table-loading-retry-timeout': 25000,
'mnesia-table-loading-retry-limit': 12,
'queue-master-locator': 'client-local'}
Expand All @@ -129,6 +130,7 @@ def test_context_ssl_off(self, config, mock_cmp_pkgrevno, mock_leader_get):
'mnesia_table_loading_retry_timeout': 25000,
'mnesia_table_loading_retry_limit': 12,
'connection_backlog': 200,
'consumer_timeout': 20000,
'queue_master_locator': 'client-local',
})

Expand Down

0 comments on commit edf7791

Please sign in to comment.