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

1k Views Asked by At

I am currently using Amazon SQS to consume message in springboot. e.g.

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

application.yaml

enter image description here

Note : amazon.sqs.queue-name is read from application.yaml which is working fine. But Now I want to read sqs-name from environment variable, so I no need to put this queue name in application.yaml file. 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. Currently I tried below workaround

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

And also want to debug, that SqsListener is listening to the correct queue.

1

There are 1 best solutions below

1
On

try this:

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