diff --git a/services/storage/src/simcore_service_storage/core/application.py b/services/storage/src/simcore_service_storage/core/application.py index aecc95bd499..b70c2cef302 100644 --- a/services/storage/src/simcore_service_storage/core/application.py +++ b/services/storage/src/simcore_service_storage/core/application.py @@ -84,8 +84,8 @@ def create_app(settings: ApplicationSettings) -> FastAPI: # noqa: C901 setup_s3(app) setup_client_session(app) - setup_rabbitmq(app) if not settings.STORAGE_WORKER_MODE: + setup_rabbitmq(app) setup_rpc_api_routes(app) setup_celery_client(app) setup_rest_api_long_running_tasks_for_uploads(app) diff --git a/services/storage/src/simcore_service_storage/modules/rabbitmq.py b/services/storage/src/simcore_service_storage/modules/rabbitmq.py index defb02a4293..27b2f291630 100644 --- a/services/storage/src/simcore_service_storage/modules/rabbitmq.py +++ b/services/storage/src/simcore_service_storage/modules/rabbitmq.py @@ -4,7 +4,6 @@ from fastapi import FastAPI from servicelib.logging_utils import log_context from servicelib.rabbitmq import ( - RabbitMQClient, RabbitMQRPCClient, wait_till_rabbitmq_responsive, ) @@ -22,16 +21,12 @@ async def on_startup() -> None: logging.INFO, msg="Storage startup Rabbitmq", ): - app.state.rabbitmq_client = None rabbit_settings: RabbitSettings | None = app.state.settings.STORAGE_RABBITMQ if not rabbit_settings: raise ConfigurationError( msg="RabbitMQ client is de-activated in the settings" ) await wait_till_rabbitmq_responsive(rabbit_settings.dsn) - app.state.rabbitmq_client = RabbitMQClient( - client_name="storage", settings=rabbit_settings - ) app.state.rabbitmq_rpc_server = await RabbitMQRPCClient.create( client_name="storage_rpc_server", settings=rabbit_settings ) @@ -42,8 +37,6 @@ async def on_shutdown() -> None: logging.INFO, msg="Storage shutdown Rabbitmq", ): - if app.state.rabbitmq_client: - await app.state.rabbitmq_client.close() if app.state.rabbitmq_rpc_server: await app.state.rabbitmq_rpc_server.close() @@ -51,14 +44,6 @@ async def on_shutdown() -> None: app.add_event_handler("shutdown", on_shutdown) -def get_rabbitmq_client(app: FastAPI) -> RabbitMQClient: - if not app.state.rabbitmq_client: - raise ConfigurationError( - msg="RabbitMQ client is not available. Please check the configuration." - ) - return cast(RabbitMQClient, app.state.rabbitmq_client) - - def get_rabbitmq_rpc_server(app: FastAPI) -> RabbitMQRPCClient: assert app.state.rabbitmq_rpc_server # nosec return cast(RabbitMQRPCClient, app.state.rabbitmq_rpc_server)