List of usage examples for org.springframework.integration.redis.inbound RedisInboundChannelAdapter stop
@Override public final void stop()
From source file:org.springframework.integration.redis.inbound.RedisInboundChannelAdapterTests.java
private void testRedisInboundChannelAdapterGuts(int iteration) throws Exception { int numToTest = 10; String redisChannelName = "testRedisInboundChannelAdapterChannel"; QueueChannel channel = new QueueChannel(); JedisConnectionFactory connectionFactory = new JedisConnectionFactory(); connectionFactory.setPort(7379);// w w w.j a va2 s . c om connectionFactory.afterPropertiesSet(); RedisInboundChannelAdapter adapter = new RedisInboundChannelAdapter(connectionFactory); adapter.setTopics("testRedisInboundChannelAdapterChannel"); adapter.setOutputChannel(channel); adapter.afterPropertiesSet(); adapter.start(); RedisMessageListenerContainer container = waitUntilSubscribed(adapter); StringRedisTemplate redisTemplate = new StringRedisTemplate(connectionFactory); redisTemplate.afterPropertiesSet(); for (int i = 0; i < numToTest; i++) { String message = "test-" + i + " iteration " + iteration; redisTemplate.convertAndSend(redisChannelName, message); logger.debug("Sent " + message); } int counter = 0; for (int i = 0; i < numToTest; i++) { Message<?> message = channel.receive(5000); if (message == null) { throw new RuntimeException("Failed to receive message # " + i + " iteration " + iteration); } assertNotNull(message); assertTrue(message.getPayload().toString().startsWith("test-")); counter++; } assertEquals(numToTest, counter); adapter.stop(); container.stop(); connectionFactory.destroy(); }