0
我能夠從我的springboot發送消息到SQS隊列,但無法使用sqslistener註釋接收,有人可以幫忙嗎?SQSlistener沒有收到消息
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);
}
我已經驗證通過goign到AWS控制檯發送,我可以看到我的消息隊列中,但他們不是來接受的方法。 配置:
@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);
}
「不起作用」根本沒有足夠的信息給任何人來幫助你。你打開了DEBUG日誌?你看到了什麼? –
嗨,多數民衆贊成在奇怪的部分,沒有錯誤,一旦我發送消息沒有什麼打印,消息去坐在隊列和聽衆根本沒有得到消息! – Bhargav