如何使用 ElastiCache 作为 Camel 幂等存储库?

How to use ElastiCache as Camel Idempotent Repository?

我正尝试将 RedisIdempotentRepository as Idempotent Consumer 用于骆驼路线。我尝试使用本地 Redis docker 容器,它使用以下代码按预期工作。

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 详细信息?

我尝试了这些配置 (link1, ) 来构建 RedisTemplate,但无法连接。

现在可以使用了。我在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...");