fetch topics from .env file
This commit was merged in pull request #15.
This commit is contained in:
@@ -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()}")
|
||||
|
||||
Reference in New Issue
Block a user