java.lang.Object
de.iip_ecosphere.platform.transport.spring.BinderFix

@Component public class BinderFix extends Object
Provides a fix for multi-binder configurations in Spring Cloud Stream at least until version 3.1.1. There, the type value for custom binders is not (always) correctly used and reported as null. We use either the Spring-like binders structure binders.properties (then like structure below spring.cloud.stream.binders, see BinderFixProperties) or, as fallback, spring.cloud.stream.defaultBinder but without settings, environment etc. Needs to be revisited for more recent versions. Code is based on StackOverflow (link in code).
Author:
Gary Russell, StackOverflow, Holger Eichelberger, SSE
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Collection<org.springframework.cloud.stream.binder.DefaultBinderFactory.Listener>
     
    private String
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.cloud.stream.binder.BinderFactory
    binderFactory(org.springframework.cloud.stream.binder.BinderTypeRegistry binderTypeRegistry, org.springframework.cloud.stream.config.BindingServiceProperties bindingServiceProperties)
    Returns the binder factory instance.
    private static Map<String,org.springframework.cloud.stream.binder.BinderConfiguration>
    getBinderConfigurations(org.springframework.cloud.stream.binder.BinderTypeRegistry binderTypeRegistry, org.springframework.cloud.stream.config.BindingServiceProperties bindingServiceProperties, String defaultBinder, BinderFixProperties properties)
    Returns the binder configurations.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • binderFactoryListeners

      @Autowired(required=false) private Collection<org.springframework.cloud.stream.binder.DefaultBinderFactory.Listener> binderFactoryListeners
    • properties

      @Autowired private BinderFixProperties properties
    • defaultBinder

      @Value("spring.cloud.stream.defaultBinder:") private String defaultBinder
  • Constructor Details

    • BinderFix

      public BinderFix()
  • Method Details

    • binderFactory

      @Bean public org.springframework.cloud.stream.binder.BinderFactory binderFactory(org.springframework.cloud.stream.binder.BinderTypeRegistry binderTypeRegistry, org.springframework.cloud.stream.config.BindingServiceProperties bindingServiceProperties)
      Returns the binder factory instance.
      Parameters:
      binderTypeRegistry - the binder type registry
      bindingServiceProperties - the binding service properties
      Returns:
      the binder factory
    • getBinderConfigurations

      private static Map<String,org.springframework.cloud.stream.binder.BinderConfiguration> getBinderConfigurations(org.springframework.cloud.stream.binder.BinderTypeRegistry binderTypeRegistry, org.springframework.cloud.stream.config.BindingServiceProperties bindingServiceProperties, String defaultBinder, BinderFixProperties properties)
      Returns the binder configurations. Copied and adapted from BindingServiceConfiguration.
      Parameters:
      binderTypeRegistry - the binder type registry
      bindingServiceProperties - the binding service properties
      defaultBinder - the default binder as second-level fallback
      properties - the binder properties as first-level fallback
      Returns:
      the binder configurations