Multiple event monitoring added

This commit is contained in:
CHIEFSOFT\ameye
2025-04-13 20:32:54 -04:00
parent 4ebc1dbfe0
commit 309bf0b138
3 changed files with 119 additions and 104 deletions
+14 -2
View File
@@ -51,7 +51,10 @@ class KafkaIntegration:
:return: The message value (decoded) or None if no message is received
"""
consumer = KafkaIntegration._get_consumer()
consumer.subscribe([topic])
# consumer.subscribe(["LOAN_REPAYMENT"])
# consumer.subscribe([topic])
consumer.subscribe(['LOAN_REPAYMENT', 'PROCESS_PAYMENT'])
logger.info(
f"Waiting for messages from topic {topic} with this timeout: {timeout}..."
@@ -94,7 +97,16 @@ class KafkaIntegration:
logger.info(
f"Received message from {msg.topic()} [{msg.partition()}] @ offset {msg.offset()}: {message}"
)
KafkaIntegration._call_disbursement_endpoint(message)
current_topic = msg.topic()
if current_topic=="PROCESS_PAYMENT":
KafkaIntegration._call_disbursement_endpoint(message)
if current_topic=="LOAN_REPAYMENT":
# Do loan repayment call here
logger.info(
f"Loan Repayment message from {msg.topic()} [{msg.partition()}] @ offset {msg.offset()}: {message}"
)
return message