Multiple binders not working with Spring-Cloud-Stream and Spring-Kubernetes on Kubernetes

5/2/2020

I have Spring-Cloud-Stream Azure Service-Bus Binder application with uses multiple binders:

spring:
  application:
    name: my-application
  cloud:
    azure:
      servicebus:
        connection-string: CON_STRING_1
    stream:
      binders:
        second-binder:
          type: servicebus-queue
          default-candidate: false
          environment:
            spring:
              cloud:
                azure:
                  servicebus:
                    connection-string: CON_STRING_2
      bindings:
        first-destination:
          destination: first-binder-queue
        second-destination:
          destination: second-binder-queue
          binder: second-binder
      function:
        definition: my-function

When I am running the application locally it connects to both binders successfully.

...
Created queue client to connection string 'Endpoint=CON_STRING_1;EntityPath=first-binder-queue;'
...
Created queue client to connection string 'Endpoint=CON_STRING_2;EntityPath=second-binder-queue;'
...

When attempting to deploy the application Kubernetes however, the second binder doesn't work. I've moved the configuration to a ConfigMap:

kind: ConfigMap
apiVersion: v1
metadata:
  # same name as the application
  name: my-application
data:
  application.yaml: |-
    spring:
      application:
        name: my-application
      cloud:
        azure:
          servicebus:
            connection-string: CON_STRING_1
        stream:
          binders:
            second-binder:
              type: servicebus-queue
              default-candidate: false
              environment:
                spring:
                  cloud:
                    azure:
                      servicebus:
                        connection-string: CON_STRING_2
          bindings:
            first-destination:
              destination: first-binder-queue
            second-destination:
              destination: second-binder-queue
              binder: second-binder
      function:
        definition: my-function

I have the spring-cloud-starter-kubernetes-config, and the configuration is read from the config map, but the second binder is not being used, and the application attempts to connect to the second queue but in the first binder

com.microsoft.azure.servicebus.primitives.MessagingEntityNotFoundException: The messaging entity 'CON_STRING_1/second-binder-queue' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions.
  1. The application does take the first connection string and other properties from the config map - the property source works as described in the Spring-Kubernetes documentation.
  2. If I deploy the application without the config map and keep the application.yaml in the jar, the application works as expected.

Any reason that only parts of the configuration will be used when switching to the ConfigMap?

-- apines
azureservicebus
java
servicebus
spring-cloud-kubernetes
spring-cloud-stream

0 Answers