@Test @RedisAvailable @SuppressWarnings("unchecked") @Ignore // JedisConnectionFactory doesn't support proper 'destroy()' and allows to create new fresh Redis // connection public void testInt3196Recovery() throws Exception { String queueName = "test.si.Int3196Recovery"; QueueChannel channel = new QueueChannel(); final List<ApplicationEvent> exceptionEvents = new ArrayList<ApplicationEvent>(); final CountDownLatch exceptionsLatch = new CountDownLatch(2); RedisQueueMessageDrivenEndpoint endpoint = new RedisQueueMessageDrivenEndpoint(queueName, this.connectionFactory); endpoint.setBeanFactory(Mockito.mock(BeanFactory.class)); endpoint.setApplicationEventPublisher( new ApplicationEventPublisher() { @Override public void publishEvent(ApplicationEvent event) { exceptionEvents.add(event); exceptionsLatch.countDown(); } }); endpoint.setOutputChannel(channel); endpoint.setReceiveTimeout(100); endpoint.setRecoveryInterval(200); endpoint.afterPropertiesSet(); endpoint.start(); int n = 0; do { n++; if (n == 100) { break; } Thread.sleep(100); } while (!endpoint.isListening()); assertTrue(n < 100); ((DisposableBean) this.connectionFactory).destroy(); assertTrue(exceptionsLatch.await(10, TimeUnit.SECONDS)); for (ApplicationEvent exceptionEvent : exceptionEvents) { assertThat(exceptionEvent, Matchers.instanceOf(RedisExceptionEvent.class)); assertSame(endpoint, exceptionEvent.getSource()); assertThat( ((IntegrationEvent) exceptionEvent).getCause().getClass(), Matchers.isIn( Arrays.<Class<? extends Throwable>>asList( RedisSystemException.class, RedisConnectionFailureException.class))); } ((InitializingBean) this.connectionFactory).afterPropertiesSet(); RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>(); redisTemplate.setConnectionFactory(this.getConnectionFactoryForTest()); redisTemplate.setEnableDefaultSerializer(false); redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); redisTemplate.afterPropertiesSet(); String payload = "testing"; redisTemplate.boundListOps(queueName).leftPush(payload); Message<?> receive = channel.receive(1000); assertNotNull(receive); assertEquals(payload, receive.getPayload()); endpoint.stop(); }