Search in sources :

Example 1 with ExceptionHandler

use of com.rabbitmq.client.ExceptionHandler in project rabbitmq-java-client by rabbitmq.

the class ExceptionHandling method forgivingConsumerHandleConsumerException.

@Test
public void forgivingConsumerHandleConsumerException() throws IOException, InterruptedException, TimeoutException {
    final CountDownLatch latch = new CountDownLatch(1);
    final ExceptionHandler eh = new ForgivingExceptionHandler() {

        @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, false);
}
Also used : DefaultExceptionHandler(com.rabbitmq.client.impl.DefaultExceptionHandler) ForgivingExceptionHandler(com.rabbitmq.client.impl.ForgivingExceptionHandler) ExceptionHandler(com.rabbitmq.client.ExceptionHandler) ForgivingExceptionHandler(com.rabbitmq.client.impl.ForgivingExceptionHandler) DefaultConsumer(com.rabbitmq.client.DefaultConsumer) Consumer(com.rabbitmq.client.Consumer) Channel(com.rabbitmq.client.Channel) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 2 with ExceptionHandler

use of com.rabbitmq.client.ExceptionHandler 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);
}
Also used : DefaultExceptionHandler(com.rabbitmq.client.impl.DefaultExceptionHandler) ForgivingExceptionHandler(com.rabbitmq.client.impl.ForgivingExceptionHandler) ExceptionHandler(com.rabbitmq.client.ExceptionHandler) DefaultConsumer(com.rabbitmq.client.DefaultConsumer) Consumer(com.rabbitmq.client.Consumer) Channel(com.rabbitmq.client.Channel) CountDownLatch(java.util.concurrent.CountDownLatch) DefaultExceptionHandler(com.rabbitmq.client.impl.DefaultExceptionHandler) Test(org.junit.Test)

Aggregations

Channel (com.rabbitmq.client.Channel)2 Consumer (com.rabbitmq.client.Consumer)2 DefaultConsumer (com.rabbitmq.client.DefaultConsumer)2 ExceptionHandler (com.rabbitmq.client.ExceptionHandler)2 DefaultExceptionHandler (com.rabbitmq.client.impl.DefaultExceptionHandler)2 ForgivingExceptionHandler (com.rabbitmq.client.impl.ForgivingExceptionHandler)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2