首页 > 解决方案 > 如何在 Spring Cloud 数据流中将 gemfire 配置为聚合器模块的消息存储

问题描述

链接 - https://github.com/spring-cloud-stream-app-starters/aggregator/tree/master/spring-cloud-starter-stream-processor-aggregator未列出 gemfire 消息存储的属性

标签: spring-cloud-dataflow

解决方案


配置GemfireMessageStore如下:

@ConditionalOnClass(GemfireMessageStore.class)
@ConditionalOnProperty(prefix = AggregatorProperties.PREFIX,
        name = "message-store-type",
        havingValue = AggregatorProperties.MessageStoreType.GEMFIRE)
@Import(ClientCacheAutoConfiguration.class)
static class Gemfire {

    @Bean
    @ConditionalOnMissingBean
    public ClientRegionFactoryBean<?, ?> gemfireRegion(GemFireCache cache, AggregatorProperties properties) {
        ClientRegionFactoryBean<?, ?> clientRegionFactoryBean = new ClientRegionFactoryBean<>();
        clientRegionFactoryBean.setCache(cache);
        clientRegionFactoryBean.setName(properties.getMessageStoreEntity());
        return clientRegionFactoryBean;
    }

    @Bean
    public MessageGroupStore messageStore(Region<Object, Object> region) {
        return new GemfireMessageStore(region);
    }

}

关键是你总是可以ClientRegionFactoryBean用你自己的来覆盖它。或者您可以考虑ClientCacheAutoConfiguration基于. 包括配置和池。没错:它不在应用程序启动器配置级别,您必须将一些自定义代码作为依赖项包含到目标绑定器特定应用程序的最终 uber jar 中。@ClientCacheApplicationClientCacheConfigurer

有关如何构建它们的更多信息,请参见 Docs:https ://docs.spring.io/spring-cloud-stream-app-starters/docs/Einstein.RC1/reference/htmlsingle/#_patching_pre_built_applications


推荐阅读