我目前在我的本地环境中使用elasticMQ来模拟SQS。 在创建SQS的生产者和使用者时,我观察到一件事,即在创建会话时,我们需要定义确认类型。
sqsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
在我的制作人项目中,我在进行会话时将其定义为AUTO_ACKNOWLEDGE
。
但是当我在使用者中定义相同的类型时,它无法从队列中获取数据,并且还指出了错误:
Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.services.sqs.AmazonSQS.deleteMessage(Lcom/amazonaws/services/sqs/model/DeleteMessageRequest;)V
at com.amazon.sqs.javamessaging.AmazonSQSMessagingClientWrapper.deleteMessage(AmazonSQSMessagingClientWrapper.java:127)
at com.amazon.sqs.javamessaging.acknowledge.AutoAcknowledger.acknowledge(AutoAcknowledger.java:33)
at com.amazon.sqs.javamessaging.acknowledge.AutoAcknowledger.notifyMessageReceived(AutoAcknowledger.java:42)
at com.amazon.sqs.javamessaging.SQSMessageConsumerPrefetch.messageHandler(SQSMessageConsumerPrefetch.java:477)
at com.amazon.sqs.javamessaging.SQSMessageConsumerPrefetch.receive(SQSMessageConsumerPrefetch.java:410)
at com.amazon.sqs.javamessaging.SQSMessageConsumer.receive(SQSMessageConsumer.java:157)
at com.abc..message.SettlementReleaseConsumer.receiveMessage(Consumer.java:45)
at com.abc.message.Consumer.main(Consumer.java:32)
有人可以解释这里发生了什么吗?
当我将使用者中的会话流程从AUTO更改为CLIENT并稍后再调用message.acknowledge()时,还有另一件事。一切正常。