Prevent KafkaStreams punctuator from shutting down on CAUGHT exception - spring-boot

Using kafkastreams with Spring Boot, I have an exception that is caught in the punctuator like so:
try {
return record.toBuilder().apiResponse(userFeed.addActivity(activity).join()).success(Boolean.TRUE).build();
} catch (StreamException e) {
e.printStackTrace();
return record.toBuilder().success(Boolean.FALSE).build();
}
However, this exception is causing the streams app to shutdown:
org.apache.kafka.streams.errors.StreamsException: stream-thread [notification-service-StreamThread-1] task [0_2] Exception caught while punctuating processor 'KSTREAM-PROCESSOR-0000000001'
2023-01-20T15:39:33.269Z ERROR 1 --- [-StreamThread-1] org.apache.kafka.streams.KafkaStreams : stream-client [notification-service] Encountered the following exception during processing and the registered exception handler opted to SHUTDOWN_CLIENT. The streams client is going to shut down now.
How do I change the registered exception handler to not shut down the client? All the docs talk about uncaught exception handlers, but I am catching this exception. I don't even know what the registered handler is.

It turns out that the exception is not in fact caught correctly because of thread weirdness, so setting the uncaught exception handler fixed this.

Related

Opportunity to catch, log, and rethrow exception when an exception occurs in kafka listener container?

I want to catch an exception that occurs within kafka listener container, log some attributes from the exception, then rethrow the exception. What is the best way to do this without modifying the existing error handling flow?
Add a MethodInterceptor to the container's adviceChain.
https://docs.spring.io/spring-kafka/docs/current/reference/html/#adviceChain

Custom Exception handling in spring boot

I have 2 filters running ,Not using controller Advice for exception handling
Catching exceptions in Filter but when I throw customized exception for ex ,UserNotAllowedException ,Filter catches NestedServletException ,Let me know If anybody has any idea on why is it happening.

Kafka streams stopping threads on exception

In a kafka streams application if the process() method in your processor throws an uncaught exception the stream task will be killed. However if you have a punctuate() method (using context.schedule()) and it throws an uncaught exception the task will not be killed. Why is this? What is the proper way to kill the task if you wanted uncaught exceptions in punctuate() to stop the task?

How did JMS implement redelivery function of onMessage?

As we known, if there is any exception is thrown at onMessage method of MessageListener, the JMS will try to consume that message again, which called "Redelivery".
But what I'm curious is how did it implement this feature? How did onMessage methods know if there is any exception is thrown? I know the answer may be a basic java knowledge. But unfortunately, I still have no idea on it.
So... is there anyone can clarify it?
This is specific to a particular JMS provider. But if your onMessage() method throws an exception, the code of the JMS provider that calls your onMessage() can just catch it, .e.g
try {
listener.onMessage(..);
} catch (Exception ex) {
//handle exception
}
And if an exception is caught, it can employ a strategy for redelivering the message. The client could send a message back to the JMS broker telling the broker that message delivery failed, and let the broker re-deliver that message.

SRVE0014E: uncaught service exception

I am getting below exception on one of our development environment. But it is working fine on another environment. unable to catch the trick. Can somebody help on this.
SRVE0014E: Uncaught service() exception root cause Jersey Spring Web
Application: `javax.servlet.ServletException: java.io.EOFException:
No content to map to Object due to end of input `
SRVE0014E appears to be application error. I would recommend checking the application log during the time of the exception thrown from the WebSphere exception. Additionally, investigate the functionality and behavior of Jersey Spring Web Application.

Resources