且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Java App Engine中实现一个原子整数?

更新时间:2022-04-06 08:33:28

您需要使用任务API 。每封邮件都是一项新任务,您可以使用循环或随机分配来分配电话号码。随着任务完成,App Engine将自动拉并执行下一个任务。您可以配置所需的吞吐率(例如,每秒10个),App Engine将为您管理所需的容量。

You need to use Task API. Every message is a new task, and you can assign phone numbers using round-robin or random assignments. As a task is completed, App Engine will automatically pull and execute the next task. You can configure the desired throughput rate (for example, 10 per second), and App Engine will manage the required capacity for you.

您可以尝试实现类似的功能你自己的,但它比你想象的困难得多 - 你必须处理并发,重试,实例关闭,内存限制等。任务API为你做所有这一切。

You can try to implement something similar on your own, but it's much more difficult than you think - you have to handle concurrency, retries, instance shutdowns, memory limits, etc. Task API does all of that for you.