我们有一组服务器正在监视共享网络装载以处理EDI文件。我们最近添加了使用RedisMetadataStore的代码,如下所示:
@Bean
public ConcurrentMetadataStore metadataStore() {
return new RedisMetadataStore(redisConnectionFactory);
}
@Bean
public FileSystemPersistentAcceptOnceFileListFilter persistentAcceptOnceFileFilter() {
return new FileSystemPersistentAcceptOnceFileListFilter(metadataStore(), "edi-file-locks");
}
@Bean
public IntegrationFlow flowInboundNetTransferFile(
@Value("${edi.incoming.directory.netTransfers}") String inboundDirectory,
@Value("${edi.incoming.age-before-ready-seconds:30}") int ageBeforeReadySeconds,
@Value("${taskExecutor.inboundFile.corePoolSize:4}") int corePoolSize,
@Qualifier("taskExecutorInboundFile") TaskExecutor taskExecutor) {
//Setup a filter to only pick up a files older than a certain age, relative to the current time. This prevents cases
//where something is writing to the file as the EDI processor is moving that file.
LastModifiedFileListFilter lastModifiedFilter = new LastModifiedFileListFilter();
lastModifiedFilter.setAge(ageBeforeReadySeconds);
return IntegrationFlows
.from(
Files
.inboundAdapter(new File(inboundDirectory))
.locker(ediDocumentLocker())
.filter(new ChainFileListFilter<File>())
.filter(new IgnoreHiddenFileListFilter())
.filter(lastModifiedFilter)
.filter(persistentAcceptOnceFileFilter()),
e -> e.poller(Pollers.fixedDelay(20000).maxMessagesPerPoll(corePoolSize).taskExecutor(taskExecutor)))
.channel(channelInboundFile())
.get();
}
这在我们较低的环境中运行良好,但是,我们在生产环境中使用Redis群集,当我们部署到该环境时,我们遇到了异常:
org.springframework.dao.InvalidDataAccessApiUsageException: WATCH is currently not supported in cluster mode.
at org.springframework.data.redis.connection.jedis.JedisClusterConnection.watch(JedisClusterConnection.java:2450)
at org.springframework.data.redis.connection.DefaultStringRedisConnection.watch(DefaultStringRedisConnection.java:951)
at org.springframework.data.redis.core.RedisTemplate$24.doInRedis(RedisTemplate.java:885)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:204)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:166)
at org.springframework.data.redis.core.RedisTemplate.watch(RedisTemplate.java:882)
at org.springframework.data.redis.support.collections.DefaultRedisMap$2.execute(DefaultRedisMap.java:225)
at org.springframework.data.redis.support.collections.DefaultRedisMap$2.execute(DefaultRedisMap.java:221)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:226)
at org.springframework.data.redis.support.collections.DefaultRedisMap.replace(DefaultRedisMap.java:221)
at org.springframework.data.redis.support.collections.RedisProperties.replace(RedisProperties.java:238)
at org.springframework.integration.redis.metadata.RedisMetadataStore.replace(RedisMetadataStore.java:154)
at org.springframework.integration.file.filters.AbstractPersistentAcceptOnceFileListFilter.accept(AbstractPersistentAcceptOnceFileListFilter.java:83)
at org.springframework.integration.file.filters.AbstractFileListFilter.filterFiles(AbstractFileListFilter.java:40)
at org.springframework.integration.file.filters.ChainFileListFilter.filterFiles(ChainFileListFilter.java:50)
at org.springframework.integration.file.DefaultDirectoryScanner.listFiles(DefaultDirectoryScanner.java:95)
at org.springframework.integration.file.FileReadingMessageSource.scanInputDirectory(FileReadingMessageSource.java:387)
at org.springframework.integration.file.FileReadingMessageSource.receive(FileReadingMessageSource.java:366)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:224)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:245)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:58)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:190)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:186)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:353)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.springframework.dao.InvalidDataAccessApiUsageException: WATCH is currently not supported in cluster mode.
at org.springframework.data.redis.connection.jedis.JedisClusterConnection.watch(JedisClusterConnection.java:2450)
at org.springframework.data.redis.connection.DefaultStringRedisConnection.watch(DefaultStringRedisConnection.java:951)
at org.springframework.data.redis.core.RedisTemplate$24.doInRedis(RedisTemplate.java:885)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:204)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:166)
at org.springframework.data.redis.core.RedisTemplate.watch(RedisTemplate.java:882)
at org.springframework.data.redis.support.collections.DefaultRedisMap$2.execute(DefaultRedisMap.java:225)
at org.springframework.data.redis.support.collections.DefaultRedisMap$2.execute(DefaultRedisMap.java:221)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:226)
at org.springframework.data.redis.support.collections.DefaultRedisMap.replace(DefaultRedisMap.java:221)
at org.springframework.data.redis.support.collections.RedisProperties.replace(RedisProperties.java:238)
at org.springframework.integration.redis.metadata.RedisMetadataStore.replace(RedisMetadataStore.java:154)
at org.springframework.integration.file.filters.AbstractPersistentAcceptOnceFileListFilter.accept(AbstractPersistentAcceptOnceFileListFilter.java:83)
at org.springframework.integration.file.filters.AbstractFileListFilter.filterFiles(AbstractFileListFilter.java:40)
at org.springframework.integration.file.filters.ChainFileListFilter.filterFiles(ChainFileListFilter.java:50)
at org.springframework.integration.file.DefaultDirectoryScanner.listFiles(DefaultDirectoryScanner.java:95)
at org.springframework.integration.file.FileReadingMessageSource.scanInputDirectory(FileReadingMessageSource.java:387)
at org.springframework.integration.file.FileReadingMessageSource.receive(FileReadingMessageSource.java:366)
at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:224)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:245)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:58)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:190)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:186)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:353)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
仔细观察,看起来这个商店正在使用RedisProperties作为后备存储,而后者又使用了群集客户端不支持的Redis客户端功能。有没有人解决过这个问题?也许写了一个支持Redis集群的备用商店?