简体   繁体   中英

Spring Cloud SQS @MessageMapping requires constant

I'm using the @MessageMapping annotation to poll my SQS queue. No problems here, however. I have a general question regarding changing the queue name depending on app environment.

Lets say that locally, in my test environment I want my @MessageMapping annotation to poll from a "Development queue name" but when I deploy to production I want to change the @MessageMapping value to a "production queue name".

@MessageMapping(ENV_SPECIFIC_QUEUE_NAME)
public void poll(String payload) {
    //do something
}

Is there a way this can be achieved through config?

@MessageMapping("${queue_name_from_properties file}")

For the moment it's no possible to dynamically set a queue name on a @MessageMapping annotation. I opened an issue to allow the usage of a property that would be set by the property placeholder.

In the meantime I recommend you to work with a CloudFormation template. With this solution you can use the logical queue name that you defined in your template and it will automatically be resolved to its physical name. Integration with CloudFormation is described here . With this solution you can start multiple stacks with the same template (dev, integration, prod,...) and you won't have any issues with queue names.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM