done with collect loan setup

This commit is contained in:
2025-04-14 13:44:56 +01:00
parent 020ab3b946
commit c76d3075af
3 changed files with 57 additions and 13 deletions
+22 -8
View File
@@ -59,7 +59,7 @@ class KafkaIntegration:
logger.info(
f"Waiting for messages from topic {topic} with this timeout: {timeout}..."
)
message =[]
message = []
try:
msg = consumer.poll(timeout=timeout)
@@ -100,10 +100,10 @@ class KafkaIntegration:
current_topic = msg.topic()
if current_topic=="PROCESS_PAYMENT":
KafkaIntegration._call_disbursement_endpoint(message)
KafkaIntegration._call_disbursement_service(message)
if current_topic=="LOAN_REPAYMENT":
# Do loan repayment call here
KafkaIntegration._call_collect_loan_service(message)
logger.info(
f"Loan Repayment message from {msg.topic()} [{msg.partition()}] @ offset {msg.offset()}: {message}"
)
@@ -124,15 +124,29 @@ class KafkaIntegration:
logger.info("Kafka consumer closed")
@staticmethod
def _call_disbursement_endpoint(message):
"""Call the disbursement endpoint with the received message"""
logger.info(f"Calling disbursement endpoint with message: {message}")
def _call_disbursement_service(message):
"""Call the disbursement service with the received message"""
logger.info(f"Calling disbursement service with message: {message}")
try:
response = SimbrellaClient.disbursement(message)
logger.info(
f"Successfully sent message to disbursement endpoint: {response.status_code}"
f"Successfully sent message to disbursement service: {response.status_code}"
)
except Exception as e:
logger.info(f"Failed to call disbursement endpoint: {e}")
logger.info(f"Failed to call disbursement service: {e}")
#raise
@staticmethod
def _call_collect_loan_service(message):
"""Call the collect loan service with the received message"""
logger.info(f"Calling collect_loan service with message: {message}")
try:
response = SimbrellaClient.collect_loan(message)
logger.info(
f"Successfully sent message to collect_loan service: {response.status_code}"
)
except Exception as e:
logger.info(f"Failed to call collect_loan service: {e}")
# raise