Add consumer-timeout config option

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
This commit is contained in:
Kevin Nasto 2024-05-29 12:26:51 -05:00
parent 87e7c1a1bd
commit edf7791f40
4 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -200,6 +200,9 @@ class RabbitMQClusterContext(object):
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')

View File

@ -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 %}

View File

@ -117,6 +117,7 @@ class TestRabbitMQClusterContext(unittest.TestCase):
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'}
@ -129,6 +130,7 @@ class TestRabbitMQClusterContext(unittest.TestCase):
'mnesia_table_loading_retry_timeout': 25000,
'mnesia_table_loading_retry_limit': 12,
'connection_backlog': 200,
'consumer_timeout': 20000,
'queue_master_locator': 'client-local',
})