use of com.rabbitmq.client.impl.DefaultExceptionHandler in project rabbitmq-java-client by rabbitmq.
the class CloseInMainLoop method specialConnectionFactory.
private ConnectionFactory specialConnectionFactory() {
ConnectionFactory f = TestUtils.connectionFactory();
f.setExceptionHandler(new DefaultExceptionHandler() {
@Override
public void handleConsumerException(Channel channel, Throwable exception, Consumer consumer, String consumerTag, String methodName) {
try {
// TODO: change this to call 4-parameter close and make 6-parm one private
((AMQConnection) channel.getConnection()).close(AMQP.INTERNAL_ERROR, "Internal error in Consumer " + consumerTag, false, exception, -1, false);
} catch (Throwable e) {
// Man, this clearly isn't our day.
// TODO: Log the nested failure
} finally {
closeLatch.countDown();
}
}
});
return f;
}
use of com.rabbitmq.client.impl.DefaultExceptionHandler in project rabbitmq-java-client by rabbitmq.
the class ExceptionHandling method defaultConsumerHandleConsumerException.
@Test
public void defaultConsumerHandleConsumerException() throws IOException, InterruptedException, TimeoutException {
final CountDownLatch latch = new CountDownLatch(1);
final ExceptionHandler eh = new DefaultExceptionHandler() {
@Override
public void handleConsumerException(Channel channel, Throwable exception, Consumer consumer, String consumerTag, String methodName) {
super.handleConsumerException(channel, exception, consumer, consumerTag, methodName);
latch.countDown();
}
};
testConsumerHandleConsumerException(eh, latch, true);
}
Aggregations