Reputation: 1298
We want to use Spring Cloud for AWS SQS, but it seems to me that it only allows us to specify region. Can we fake it so that it uses ElasticMQ (on localhost:9320 for instance)? I didn't find an easy way to do this without editing hosts file and putting certificates on localhost
Upvotes: 1
Views: 1441
Reputation: 1298
I found a way after some research. You should set an endpoint after AmazonSQS instance is injected in order to override the already set endpoint, as so:
@Autowired
public void setAmazonSqs(AmazonSQS amazonSqs)
{
this.amazonSqs = amazonSqs;
// use elasticMQ if spring default profile is used; no active profiles
if (environment.getActiveProfiles().length == 0)
{
amazonSqs.setEndpoint("http://localhost:9320");
}
}
it is up to you if you're going to use QueueMessagingTemplate
, anyway you should modify the injected AmazonSQS instance.
Upvotes: 4