Class CustomSuffixBindHandler

  • All Implemented Interfaces:
    org.springframework.boot.context.properties.bind.BindHandler

    public class CustomSuffixBindHandler
    extends org.springframework.boot.context.properties.bind.AbstractBindHandler
    Custom Spring BindHandler to support dynamic re-naming of Spring Cloud Stream BindingProperties at runtime. This supports use cases where there is a need to share a single message broker instance across multiple environment specific or region specific application instances. To facilitate segmenting destinations and groups for each environment, this custom bind handler allows modifying each ALREADY DEFINED Spring Cloud Stream destination and group definitions with a particular suffix to allow segmentation across environments via a property. e.g. if you had existing bindings already defined like: spring.cloud.stream.binding.input.destination=topic spring.cloud.stream.binding.input.group=subscription Assuming the appropriate SUFFIX is configured CustomCloudstreamBindingConfiguration, this custom bind handler will modify the properties and bind the following: "topic-SUFFIX" and "subscription-SUFFIX" instead
    Author:
    Elbert Bautista (elbertbautista)
    • Field Summary

      • Fields inherited from interface org.springframework.boot.context.properties.bind.BindHandler

        DEFAULT
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> org.springframework.boot.context.properties.bind.Bindable<T> onStart​(org.springframework.boot.context.properties.source.ConfigurationPropertyName name, org.springframework.boot.context.properties.bind.Bindable<T> target, org.springframework.boot.context.properties.bind.BindContext context)  
      Object onSuccess​(org.springframework.boot.context.properties.source.ConfigurationPropertyName name, org.springframework.boot.context.properties.bind.Bindable<?> target, org.springframework.boot.context.properties.bind.BindContext context, Object result)  
      • Methods inherited from class org.springframework.boot.context.properties.bind.AbstractBindHandler

        onFailure, onFinish
      • Methods inherited from interface org.springframework.boot.context.properties.bind.BindHandler

        onCreate
    • Method Detail

      • onStart

        public <T> org.springframework.boot.context.properties.bind.Bindable<T> onStart​(org.springframework.boot.context.properties.source.ConfigurationPropertyName name,
                                                                                        org.springframework.boot.context.properties.bind.Bindable<T> target,
                                                                                        org.springframework.boot.context.properties.bind.BindContext context)
        Specified by:
        onStart in interface org.springframework.boot.context.properties.bind.BindHandler
        Overrides:
        onStart in class org.springframework.boot.context.properties.bind.AbstractBindHandler
      • onSuccess

        public Object onSuccess​(org.springframework.boot.context.properties.source.ConfigurationPropertyName name,
                                org.springframework.boot.context.properties.bind.Bindable<?> target,
                                org.springframework.boot.context.properties.bind.BindContext context,
                                Object result)
        Specified by:
        onSuccess in interface org.springframework.boot.context.properties.bind.BindHandler
        Overrides:
        onSuccess in class org.springframework.boot.context.properties.bind.AbstractBindHandler