I am able to send messages to SQS queue from my springboot but not able to receive using sqslistener annotation, can someone help?
public void send(String message) {
queueMessagingTemplate.convertAndSend("test-queue", MessageBuilder.withPayload(message).build());
}
@SqsListener(value = "test-queue", deletionPolicy = SqsMessageDeletionPolicy.NEVER)
public void receive(String message)
{
System.out.println("message: " + message);
}
I have verified send by goign to AWS console, i can see my messages in queue, but they are not coming to receive method. config:
@Bean
public AmazonSQSAsyncClient amazonSQSAsyncClient()
{
AmazonSQSAsyncClient amazonSQSAsyncClient= new AmazonSQSAsyncClient(amazonAWSCredentials());
if (!StringUtils.isEmpty(amazonSqsEndpoint)) {
amazonSQSAsyncClient.setEndpoint(amazonSqsEndpoint);
}
}
@Bean
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory() {
SimpleMessageListenerContainerFactory msgListenerContainerFactory = new SimpleMessageListenerContainerFactory();
msgListenerContainerFactory.setAmazonSqs(amazonSQSAsyncClient());
return msgListenerContainerFactory;
}
@Bean
public QueueMessagingTemplate queueMessagingTemplate(AmazonSQSAsync amazonSqs) {
return new QueueMessagingTemplate(amazonSQSAsyncClient());
}
@Bean
public BasicAWSCredentials amazonAWSCredentials() {
return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey);
}