use of com.rabbitmq.client.impl.StrictExceptionHandler in project rabbitmq-java-client by rabbitmq.
the class StrictExceptionHandlerTest method tooLongClosingMessage.
@Test
public void tooLongClosingMessage() throws Exception {
ConnectionFactory cf = TestUtils.connectionFactory();
final CountDownLatch latch = new CountDownLatch(1);
cf.setExceptionHandler(new StrictExceptionHandler() {
@Override
public void handleConsumerException(Channel channel, Throwable exception, Consumer consumer, String consumerTag, String methodName) {
try {
super.handleConsumerException(channel, exception, consumer, consumerTag, methodName);
} catch (IllegalArgumentException e) {
fail("No exception should caught");
}
latch.countDown();
}
});
try (Connection c = cf.newConnection()) {
Channel channel = c.createChannel();
String queue = channel.queueDeclare().getQueue();
channel.basicConsume(queue, new VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongClassName(channel));
channel.basicPublish("", queue, null, new byte[0]);
assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue();
}
}
Aggregations