1
votes

We have a Spring Boot Microservice that as well as having HTTP endpoints uses Spring Cloud Bus to pick up refresh events (from rabbit) and also has a Spring Cloud Stream Sink that picks up custom messages from another rabbit topic.

After updating to Spring Boot 2.4.1 and Spring Cloud 2020.0.0 everything seemed to be working until we discovered Spring Cloud Bus was no longer picking up events. Looking into this it turned out some of the Spring Cloud Bus internal channels where not getting created.

This wasn't happening in another service that didn't have the stream functionality as well so we tested disabling that and the bus functionality then started working. So it was obviously some sort of interference between the old style stream model and the newer Spring Cloud Bus.

After updating the our sink to use the new function model I still had issues and eventually got both to work by including the following lines in our application.yml:

spring:
  cloud:
    stream:
      bindings.mySink-in-0.destination: mytopic
      function.definition: busConsumer;mySink

So I have the following questions

  1. Did I miss something or should there be better documentation on how stream / bus can affect each other and the migration to 2020.0.0?
  2. Does my current configuration look correct?
  3. It doesn't seem right to have to include busConsumer here - should the auto configuration for it not be able to 'combine it in' with any other stream config?
  4. What's the difference between spring.cloud.stream.function.definition and spring.cloud.function.definition? I've seen both in documentation and Spring Cloud Bus seems to be also setting spring.cloud.function.definition=busConsumer
1
The spring.cloud.stream.function.definition is only there for backward compatibility. It is the same as spring.cloud..function.definition. Also, this appears to be more of a cloud-bus question so hopefully someone will follow upOleg Zhurakousky
@OlegZhurakousky is right. Spring Cloud Bus post-process the the property spring.cloud.function.definition (not the other) adding the bus consumer, so you should use this property. Also take into account that, as far as I know, spring-cloud-bus is not compatible anymore with spring-cloud-stream legacy approach.Jordi Martínez

1 Answers

0
votes

In org.springframework.cloud.stream.function.FunctionConfiguration, It does a search for @EnableBinding.

if (ObjectUtils.isEmpty(applicationContext.getBeanNamesForAnnotation(EnableBinding.class)))

If found, functional binding is disabled. See this

logger.info("Functional binding is disabled due to the presense of @EnableBinding annotation in your configuration");

After the upgrade, we need to transform our Listener classes to use functional interface in order to activate the functional binding. After that, cloud bus consumer binding will be created too.