-
-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Why do we need this improvement?
The current implementation of the PublisherServiceImpl
class lacks proper exception handling mechanisms during Kafka message publishing. This omission can lead to unhandled exceptions, potentially causing application instability and message loss. Implementing robust exception handling is crucial to ensure reliable message delivery and maintain system resilience.
How will this change help?
Addressing this issue will enhance the reliability and stability of the Kafka producer by ensuring that exceptions are properly managed, thereby reducing the risk of message loss and application crashes.
Screenshots
NA
How could it be implemented/designed?
-
Implement Asynchronous Send with Callback:
Utilize the
kafkaTemplate.send(message)
method along with aListenableFutureCallback
to handle success and failure scenarios during message publishing. -
Introduce Synchronous Send with Exception Handling:
Use the
kafkaTemplate.send(message).get(10, TimeUnit.SECONDS)
method within a try-catch block to manage potential exceptions such asInterruptedException
,ExecutionException
, andTimeoutException
.
🚧 Breaking changes
No
👀 Have you checked for similar open issues?
- I checked and didn't find a similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue?
Yes I am willing to submit a PR!