Grails RabbitMQ native:内插凭据上的 AuthenticationFailureException

Grails RabbitMQ native: AuthenticationFailureException on interpolated credentials

使用 Grails RabbitMQ-native 插件,在 application.yml 中的 Rabbit 连接配置中使用环境变量插值时,插值不起作用:

rabbitmq:
    connections:
      - name: defaultConnection
        host: example.com
        username: ${RABBITMQ_USER}
        password: bar

硬编码相同凭据时导致 AuthenticationFailureException。

有解决办法吗?我不想将凭据硬编码到我们的 RabbitMQ 实例...

解决方法是在 application.groovy 文件中定义 rabbitMQ 连接。

示例:

// Rabbitmq connection configuration
rabbitmq {
    connections = [
            [
                    name: "main",
                    host: System.getenv('RABBITMQ_HOST'),
                    username: System.getenv('RABBITMQ_USER'),
                    password: System.getenv('RABBITMQ_PASS')
            ]
    ]
}