2016-09-28 55 views
1

我尝试使用RedisIdempotentRepository作为Idempotent Consumer骆驼路线。我尝试使用本地Redis Docker容器,并按照预期使用以下代码工作。如何使用ElastiCache作为Camel Idempotent Repository?

IdempotentRepository redisIdempotentRepository = new RedisIdempotentRepository("redis"); 
from(source) 
    .idempotentConsumer(simple("${in.header.CamelFileName}"), redisIdempotentRepository) 
    .log("Uploading file ${file:name} started...") 
    .to(destination) 
    .log("Uploading file ${file:name} completed..."); 

没有提供任何细节,它连接到localhost:6379。我如何提供ElastiCache详细信息以进行连接?

我试过这些配置(link1link2)来构建RedisTemplate并且无法连接。

+0

您需要告知有关错误或您看到的内容的更多详细信息 - 无法连接。并检查骆驼春季redis的单元测试,可以有一些测试,可以告诉你如何做到这一点:https://github.com/apache/camel/tree/master/components/camel-spring-redis –

+0

谢谢@ClausIbsen,这是AWS安全组的问题。我没有提前知道节点与现有的安全组相关联。我认为它可以通过VPC访问。 – Gangaraju

回答

0

它现在工作。我在redis节点关联安全组的入站规则中添加了6379端口。

JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(); 
jedisConnectionFactory.setHostName("<cluster-name>.mdbnso.0001.use1.cache.amazonaws.com"); 
jedisConnectionFactory.setPort(6379); 
jedisConnectionFactory.afterPropertiesSet(); 

RedisTemplate redisTemplate = new RedisTemplate(); 
redisTemplate.setConnectionFactory(jedisConnectionFactory); 
redisTemplate.afterPropertiesSet(); 

IdempotentRepository redisIdempotentRepository = new RedisIdempotentRepository(redisTemplate, "redis"); 

from(source) 
    .idempotentConsumer(simple("${in.header.CamelFileName}"), redisIdempotentRepository) 
    .log("Uploading file ${file:name} started...") 
    .to(destination) 
    .log("Uploading file ${file:name} completed...");