Несколько связывателей не работают с Spring-Cloud-Stream и Spring-Kubernetes в Kubernetes - PullRequest
1 голос
/ 02 мая 2020

У меня Spring-Cloud-Stream Azure Приложение Binder Service-Bus с несколькими связывателями использует:

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

Когда я запускаю приложение локально, оно успешно соединяется с обоими связывателями.

...
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;'
...

При попытке развернуть приложение Kubernetes, однако, второй механизм связывания не работает. Я перенес конфигурацию в 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

У меня есть spring-cloud-starter-kubernetes-config, и конфигурация считывается из карты конфигурации, но второй механизм связывания не используется, и приложение пытается подключиться ко второй очереди, но в 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. Приложение получает первую строку подключения и другие свойства из карты конфигурации - источник свойств работает, как описано в Spring-Kubernetes документации .
  2. Если я разверну приложение без карты конфигурации и сохраню application.yaml в банке, приложение будет работать как и ожидалось .

Любая причина, по которой при переключении на ConfigMap?

будут использоваться только части конфигурации
...