fetch topics from .env file

This commit was merged in pull request #15.
This commit is contained in:
2025-04-16 19:41:55 +01:00
parent e75a025dab
commit 4abafa9a6c
5 changed files with 10 additions and 10 deletions
+5 -7
View File
@@ -42,22 +42,20 @@ class KafkaIntegration:
)
@staticmethod
def receive_disbursement_messages(topic, timeout):
def receive_messages(topics, timeout):
"""
Receive messages from a Kafka topic.
:param topic: The Kafka topic to subscribe to
:param topics: The Kafka topics to subscribe to
:param timeout: Time to wait for a message (in seconds)
:return: The message value (decoded) or None if no message is received
"""
consumer = KafkaIntegration._get_consumer()
# consumer.subscribe(["PROCESS_PAYMENT"])
# consumer.subscribe([topic])
consumer.subscribe(['LOAN_REPAYMENT', 'PROCESS_PAYMENT'])
consumer.subscribe(topics)
logger.info(
f"Waiting for messages from topic {topic} with this timeout: {timeout}..."
f"Waiting for messages from topic {topics} with this timeout: {timeout}..."
)
message = []
try:
@@ -70,7 +68,7 @@ class KafkaIntegration:
)
if msg is None:
logger.info(f"No message received from topic {topic} within timeout")
logger.info(f"No message received from topic {topics} within timeout")
return None
if msg.error():
logger.info(f"Consumer error: {msg.error()}")