1

我有使用多个活页夹的 Spring-Cloud-Stream Azure Service-Bus Binder 应用程序:

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, 并且配置是从配置映射中读取的,但是第二个绑定器没有被使用,并且应用程序尝试连接到第二个队列但在第一个绑定器中

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在 jar 中,则应用程序将按预期工作

切换到 时仅使用部分配置的任何原因ConfigMap

4

0 回答 0