我有以下代码从 SQS 队列中检索消息。我正在使用 aAmazonSQSBufferedAsyncClient
从队列中检索消息。每 5 分钟调用一次固定延迟SingleThreadedExecutor
唤醒receiveMessage
。队列中启用长轮询
@Service
public class AmazonQueueService
implements QueueService<String> {
@Autowired
private AmazonSQSBufferedAsyncClient sqsAsyncClient;
@Value("${aws.sqs.queueUrl}")
private String queueUrl;
@Override
public List<Message<String>> receiveMessage() {
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
ReceiveMessageResult result = sqsAsyncClient.receiveMessage(receiveMessageRequest);
LOG.debug("Size=" + result.getMessages().size());
return Lists.transform(result.getMessages(), ......);
}
.....
}
问题是当我检查 AWS 控制台时,消息总是在进行中,但应用程序中从未收到它(大小总是打印为 0)。看起来AmazonSQSBufferedAsyncClient
正在从队列中读取消息,但没有在receiveMessage
调用中返回。
有任何想法吗?