Problem
The documentation for AbstractMessageListenerContainer says it will log any such exception at the error level
, but the code in AbstractMessageListenerContainer
's invokeErrorHandler()
method logs with WARN level.
Also reported in comments on this Stack Overflow answer: https://stackoverflow.com/a/8922645/6113915
Reproduce
Code to create error in JMS Listener and reproduce WARN log.
@JmsListener(destination = "SOME_DEST", containerFactory = "jmsListenerContainerFactory")
fun receiveMessage(message: String, @Header("NON_EXISTING_HEADER") correlationId: String) {
// Will throw org.springframework.jms.listener.adapter.ListenerExecutionFailedException because header is non existing
}
Log from above code:
2023-06-23 08:11:04,488 WARN [org.springframework.jms.JmsListenerEndpointContainer#0-1] AbstractMessageListenerContainer: Execution of JMS message listener failed, and no ErrorHandler has been set.
org.springframework.jms.listener.adapter.ListenerExecutionFailedException: Listener method could not be invoked with incoming message
Comment From: sbrannen
Hi @Sti2nd,
Congratulations on submitting your first issue for the Spring Framework! π
The documentation has been updated for inclusion in 6.0.11.
Comment From: Sti2nd
Thank you π€ Good quick work by yourself, @sbrannen!
FYI I created an error handler just to log with error level instead because I can't think of a reason I don't want to know about these errors.
connectionFactory.setErrorHandler { t -> log.error("Error in listener", t) }
I assume that there is some reason for Spring to hide these errors in warning π€ If anyone knows I would gladly learn
Comment From: sbrannen
I assume that there is some reason for Spring to hide these errors in warning π€ If anyone knows I would gladly learn
It's been that way since before Spring Framework 3.0, as far as I can tell.
I believe it's simply to reduce the amount of log output when an application is configured to only display ERROR level logging.
Though perhaps @jhoeller can provide further insight.