Search code examples
spring-cloud-dataflow

How to configure gemfire as message store for aggregator module in spring cloud data flow


Link - https://github.com/spring-cloud-stream-app-starters/aggregator/tree/master/spring-cloud-starter-stream-processor-aggregator does not list property for gemfire message store


Solution

  • The GemfireMessageStore is configured like this:

    @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);
        }
    
    }
    

    The point is that you always can override that ClientRegionFactoryBean with your own. Or you can take into account that ClientCacheAutoConfiguration is based on the @ClientCacheApplication, which, in turn, allows you to have a ClientCacheConfigurer bean and provide whatever is sufficient for your client cache configuration. Including config and pool. That's right: it is not on the app starter configuration level and you have to right some custom code to be included as a dependency into the final uber jar for target binder-specific application.

    More info how to build them is here in Docs: https://docs.spring.io/spring-cloud-stream-app-starters/docs/Einstein.RC1/reference/htmlsingle/#_patching_pre_built_applications