SQSlistener not receiving messages

╄→尐↘猪︶ㄣ 提交于 2019-12-24 08:07:16

问题


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);
}

回答1:


Turns out i had a typo in the queue names in SQS console and my code, my bad.



来源:https://stackoverflow.com/questions/43805823/sqslistener-not-receiving-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!