use of com.meltwater.rxrabbit.util.MonitoringTestThreadFactory in project rxrabbit by meltwater.
the class RxRabbitTests method consumer_closes_internal_subscriber_on_error_during_connection.
@Test
public void consumer_closes_internal_subscriber_on_error_during_connection() throws Exception {
MonitoringTestThreadFactory threadFactory = new MonitoringTestThreadFactory();
Scheduler threadPoolScheduler = new CachedThreadScheduler(threadFactory);
RxJavaHooks.setOnIOScheduler((ioScheduler) -> threadPoolScheduler);
CountDownLatch retries = new CountDownLatch(10);
ConsumerSettings consumerSettings = new ConsumerSettings().withRetryCount(ConsumerSettings.RETRY_FOREVER).withNumChannels(1).withPreFetchCount(1024).withBackoffAlgorithm(integer -> {
retries.countDown();
return 1;
});
Observable<Message> consumer = new DefaultConsumerFactory(channelFactory, consumerSettings).createConsumer("non-existent-queue");
Subscription subscribe = consumer.subscribe();
retries.await();
subscribe.unsubscribe();
assertThat(threadFactory.getAliveThreads(), lessThan(10));
}
Aggregations