From e58bbde16a724ae3bd0a624724f4a506471f83c0 Mon Sep 17 00:00:00 2001 From: Cyrus Mobini Date: Tue, 27 Aug 2024 15:40:08 -0400 Subject: [PATCH] Added support for temporary queue + UUID queue name --- .../components/inputs_outputs/broker_base.py | 4 ++++ .../components/inputs_outputs/broker_input.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/solace_ai_connector/components/inputs_outputs/broker_base.py b/src/solace_ai_connector/components/inputs_outputs/broker_base.py index df4bb5e..157177b 100644 --- a/src/solace_ai_connector/components/inputs_outputs/broker_base.py +++ b/src/solace_ai_connector/components/inputs_outputs/broker_base.py @@ -11,6 +11,7 @@ from ..component_base import ComponentBase from ...common.message import Message from ...common.messaging.messaging_builder import MessagingServiceBuilder +import uuid # TBD - at the moment, there is no connection sharing supported. It should be possible # to share a connection between multiple components and even flows. The changes @@ -138,3 +139,6 @@ def get_acknowledgement_callback(self): def start(self): pass + + def generate_uuid(self): + return str(uuid.uuid4()) diff --git a/src/solace_ai_connector/components/inputs_outputs/broker_input.py b/src/solace_ai_connector/components/inputs_outputs/broker_input.py index 507702a..841c8ee 100644 --- a/src/solace_ai_connector/components/inputs_outputs/broker_input.py +++ b/src/solace_ai_connector/components/inputs_outputs/broker_input.py @@ -38,13 +38,13 @@ }, { "name": "broker_queue_name", - "required": True, - "description": "Queue name for broker", + "required": False, + "description": "Queue name for broker, if not provided it will use a temporary queue", }, { "name": "temporary_queue", "required": False, - "description": "Whether to create a temporary queue that will be deleted after disconnection", + "description": "Whether to create a temporary queue that will be deleted after disconnection, defaulted to True if broker_queue_name is not provided", "default": False, }, { @@ -91,7 +91,12 @@ def __init__(self, **kwargs): super().__init__(info, **kwargs) self.need_acknowledgement = True self.temporary_queue = self.get_config("temporary_queue", False) - self.broker_properties["temporary_queue"] = self.temporary_queue + # If broker_queue_name is not provided, use temporary queue + if not self.get_config("broker_queue_name"): + self.temporary_queue = True + self.broker_properties["temporary_queue"] = True + # Generating a UUID for the queue name + self.broker_properties["queue_name"] = self.generate_uuid() self.connect() def invoke(self, message, data):