AMQP-129: allow client RuntimeExceptions to propagate in RabbitTemplate

This commit is contained in:
Dave Syer
2011-03-23 17:46:52 +00:00
parent df5d22169d
commit 98d26b40b0
2 changed files with 7 additions and 5 deletions

View File

@@ -299,7 +299,11 @@ public class RabbitTemplate extends RabbitAccessor implements RabbitOperations {
if (isChannelLocallyTransacted(channel)) {
resourceHolder.rollbackAll();
}
throw convertRabbitAccessException(ex);
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
} else {
throw convertRabbitAccessException(ex);
}
} finally {
ConnectionFactoryUtils.releaseResources(resourceHolder);
}

View File

@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.amqp.UncategorizedAmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
@@ -106,9 +105,8 @@ public class RabbitTemplateIntegrationTests {
}
});
fail("Expected PlannedException");
} catch (UncategorizedAmqpException e) {
// TODO: allow client exception to propagate if no AMQP related
assertTrue(e.getCause() instanceof PlannedException);
} catch (Exception e) {
assertTrue(e instanceof PlannedException);
}
String result = (String) template.receiveAndConvert(ROUTE);
assertEquals("message", result);