简体   繁体   English

对于@sqslistener,从环境变量传递的值不是.yaml 文件

[英]For @sqslistener, value pass from environment variable other than .yaml file

I am currently using Amazon SQS to consume message in springboot.我目前正在使用 Amazon SQS 在 springboot 中使用消息。 eg例如

@sqslistener(value ="amazon.sqs.queue-name")
public void sesListener() {
// some statement
}

application.yaml应用程序.yaml

在此处输入图像描述

Note: amazon.sqs.queue-name is read from application.yaml which is working fine.注意: amazon.sqs.queue-name是从 application.yaml 读取的,它工作正常。 But Now I want to read sqs-name from environment variable, so I no need to put this queue name in application.yaml file.但是现在我想从环境变量中读取 sqs-name,所以我不需要把这个队列名放在 application.yaml 文件中。 Can anyone please help me out for this use-case?谁能帮我解决这个用例?

FYI: I want to use something like env.getProperty("queue-name") to read queue-name from environment variable.仅供参考:我想使用类似 env.getProperty("queue-name") 的东西从环境变量中读取队列名称。 Currently I tried below workaround目前我尝试了以下解决方法

@SqsListener(value = "#{ environment['queue-name'] }"

And also want to debug, that SqsListener is listening to the correct queue.并且还想调试,SqsListener 正在侦听正确的队列。

try this:尝试这个:

@sqslistener(value ="${amazon.sqs.queue-name}")
public void sesListener() {
// some statement
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Kubernetes yaml配置中定义的环境值传递给java spring配置文件 - pass environment value defined in Kubernetes yaml config to java spring profile Sping Boot - 除了 application.yaml 之外的单独配置文件 - Sping Boot - Separate config file other than application.yaml redisson.yaml环境变量 - redisson.yaml environment variable Spring 引导:从 YAML 文件加载@Value - Spring Boot: Load @Value from YAML file SQSListener 不使用队列中的消息 - SQSListener not consuming messages from queue openshift 从文件中设置环境变量 - openshift set environment variable from a file 如何将 yaml 文件中的变量读入 application.properties? - How to read a variable from a yaml file into the application.properties? Spring 引导 + Docker 撰写:如何覆盖“地图” <string, list<string> &gt;' 来自 yaml 属性的环境变量</string,> - Spring Boot + Docker Compose: How to override 'Map<String, List<String>>' environment variable from yaml properties Spring Boot不读取环境特定的YAML文件 - Spring boot not reading environment specific YAML file 如何将动态主题名称从环境变量传递给@KafkaListener(topics) - How to pass dynamic topic name to @KafkaListener(topics) from environment variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM