From 08ac69c236c325da691b9b935edc8fdef3c8c98c Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 13 Dec 2023 12:24:37 +0000 Subject: [PATCH] Limit rabbitmq prefetch and use default rabbitmq (#180) * Limit rabbitmq prefetch and use default rabbitmq Shouldn't need to increase the timeout for rabbitmq * Use default rabbitmq everywhere * Don't prefetch messages --- docker-compose.yml | 6 +----- docker/queue/Dockerfile | 16 ---------------- pixl_core/src/core/patient_queue/subscriber.py | 2 ++ pixl_core/tests/docker-compose.yml | 3 --- pixl_pacs/tests/docker-compose.yml | 4 +--- 5 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 docker/queue/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index dbbcfc14c..b94b7a2dc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -199,11 +199,7 @@ services: restart: "no" queue: - build: - context: . - dockerfile: ./docker/queue/Dockerfile - args: - <<: *build-args-common + image: rabbitmq:3.11.2-management environment: RABBITMQ_DEFAULT_USER: ${RABBITMQ_USERNAME} RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD} diff --git a/docker/queue/Dockerfile b/docker/queue/Dockerfile deleted file mode 100644 index bfa1aa970..000000000 --- a/docker/queue/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) University College London Hospitals NHS Foundation Trust -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FROM rabbitmq:3.11.2-management - -RUN echo "consumer_timeout = 3600000" >> /etc/rabbitmq/rabbitmq.conf \ No newline at end of file diff --git a/pixl_core/src/core/patient_queue/subscriber.py b/pixl_core/src/core/patient_queue/subscriber.py index b678c256c..cf5361297 100644 --- a/pixl_core/src/core/patient_queue/subscriber.py +++ b/pixl_core/src/core/patient_queue/subscriber.py @@ -47,6 +47,8 @@ async def __aenter__(self) -> "PixlConsumer": """Establishes connection to queue.""" self._connection = await aio_pika.connect_robust(self._url) self._channel = await self._connection.channel() + # Don't prefetch messages + await self._channel.set_qos(prefetch_count=1) self._queue = await self._channel.declare_queue(self.queue_name) return self diff --git a/pixl_core/tests/docker-compose.yml b/pixl_core/tests/docker-compose.yml index 143787f57..93fcf81ad 100644 --- a/pixl_core/tests/docker-compose.yml +++ b/pixl_core/tests/docker-compose.yml @@ -18,9 +18,6 @@ services: queue: container_name: pixl-test-queue - build: - context: ../.. - dockerfile: docker/queue/Dockerfile image: rabbitmq:3.11.2-management environment: RABBITMQ_DEFAULT_USER: guest diff --git a/pixl_pacs/tests/docker-compose.yml b/pixl_pacs/tests/docker-compose.yml index 97846f19f..cefdc4d79 100644 --- a/pixl_pacs/tests/docker-compose.yml +++ b/pixl_pacs/tests/docker-compose.yml @@ -115,9 +115,7 @@ services: queue: container_name: pixl-test-queue - build: - context: ../.. - dockerfile: docker/queue/Dockerfile + image: rabbitmq:3.11.2-management healthcheck: test: rabbitmq-diagnostics -q ping interval: 30s