Skip to content

Commit

Permalink
Merge pull request #1285 from OCR-D/rabbitmq_heartbeat_env
Browse files Browse the repository at this point in the history
Rabbitmq heartbeat env
  • Loading branch information
kba authored Oct 10, 2024
2 parents 926cb97 + 7f60559 commit 3e736a7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/ocrd/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
\b
{config.describe('OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS')}
\b
{config.describe('OCRD_NETWORK_RABBITMQ_HEARTBEAT')}
\b
{config.describe('OCRD_PROFILE_FILE')}
\b
{config.describe('OCRD_PROFILE', wrap_text=False)}
Expand Down
4 changes: 2 additions & 2 deletions src/ocrd_network/rabbitmq_utils/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any, Optional, Union
from pika import BasicProperties, BlockingConnection, ConnectionParameters, PlainCredentials
from pika.adapters.blocking_connection import BlockingChannel
from ocrd_utils import config
from .constants import (
DEFAULT_EXCHANGER_NAME,
DEFAULT_EXCHANGER_TYPE,
Expand Down Expand Up @@ -69,8 +70,7 @@ def open_blocking_connection(
port=port,
virtual_host=vhost,
credentials=credentials,
# TODO: The heartbeat should not be disabled (0)!
heartbeat=0
heartbeat=config.OCRD_NETWORK_RABBITMQ_HEARTBEAT
),
)
return blocking_connection
Expand Down
14 changes: 12 additions & 2 deletions src/ocrd_utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,19 @@ def _ocrd_download_timeout_parser(val):
default=(True, ''))

config.add("OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS",
description="Number of attempts for a RabbitMQ client to connect before failing.",
description="Number of attempts for a RabbitMQ client to connect before failing.",
parser=int,
default=(True, 3))

config.add(
name="OCRD_NETWORK_RABBITMQ_HEARTBEAT",
description="""
Controls AMQP heartbeat timeout (in seconds) negotiation during connection tuning. An integer value always overrides the value
proposed by broker. Use 0 to deactivate heartbeat.
""",
parser=int,
default=(True, 3))
default=(True, 0)
)

config.add(name="OCRD_NETWORK_SOCKETS_ROOT_DIR",
description="The root directory where all mets server related socket files are created",
Expand Down
12 changes: 10 additions & 2 deletions tests/network/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,19 @@

test_config.add(
name="OCRD_NETWORK_RABBITMQ_CLIENT_CONNECT_ATTEMPTS",
description="Number of attempts for a RabbitMQ client to connect before failing",
parser=int,
default=(True, 3)
)

test_config.add(
name="OCRD_NETWORK_RABBITMQ_HEARTBEAT",
description="""
Number of attempts for a RabbitMQ client to connect before failing
Controls AMQP heartbeat timeout (in seconds) negotiation during connection tuning. An integer value always overrides the value
proposed by broker. Use 0 to deactivate heartbeat.
""",
parser=int,
default=(True, 3)
default=(True, 0)
)

test_config.add(
Expand Down

0 comments on commit 3e736a7

Please sign in to comment.