spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.6k stars 38.13k forks source link

Add error handling strategy to MessageListenerContainer [SPR-4733] #9410

Closed spring-projects-issues closed 9 years ago

spring-projects-issues commented 16 years ago

Dave Syer opened SPR-4733 and commented

Add error handling strategy to MessageListenerContainer. There is a protected method to override, but it would be preferable to have a configurable strategy, such as could be provided by an error handler, then I won't have to do this just to get the listener error re-thrown:

protected void handleListenerException(Throwable ex) {
    if (!isSessionTransacted()) {
        // Log the exceptions in base class if not transactional anyway
        super.handleListenerException(ex);
        return;
    }
    logger.debug("Re-throwing exception in container.");
    if (ex instanceof RuntimeException) {
        // We need to re-throw so that an enclosing non-JMS transaction can
        // rollback...
        throw (RuntimeException) ex;
    }
    else if (ex instanceof Error) {
        // Just re-throw Error instances because otherwise unit tests just
        // swallow exceptions from EasyMock and JUnit.
        throw (Error) ex;
    }
}   

Affects: 2.5.2

1 votes, 2 watchers

spring-projects-issues commented 9 years ago

Juergen Hoeller commented

Closing groups of outdated issues. Please reopen if still relevant.