英文:
do QueueMessagingTemplate run async or sync in spring boot
问题
现在我使用QueueMessagingTemplate来消费SQS中的消息,我观察到在类QueueMessagingTemplate中有private final AmazonSQSAsync amazonSqs
。当我在这个类中使用方法(例如我使用receive
)时,AmazonSQSAsync
是异步还是同步运行的?
英文:
Now I use QueueMessagingTemplate to consume message in SQS, and I observe private final AmazonSQSAsync amazonSqs
in the class QueueMessagingTemplate
. Does AmazonSQSAsync
run async or sync when I use a method in this class (for example I use receive
)?
答案1
得分: 1
AmazonSQSAsync
根据 AWS Java SDK:
用于异步访问 Amazon SQS 的接口。每个异步方法将返回一个代表异步操作的 Java Future 对象;接受 AsyncHandler 的重载可用于在异步操作完成时接收通知。
因此它会以同步方式运行,但会返回一个 future 对象。
英文:
AmazonSQSAsync
according to the AWS Java SDK:
> Interface for accessing Amazon SQS asynchronously. Each asynchronous method will return a Java Future object representing the asynchronous operation; overloads which accept an AsyncHandler can be used to receive notification when an asynchronous operation completes.
So it will run sync but return a future object.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论