You need to approach this with three separate steps:
Deploy a Sharding Counter to generate a monotonously increasing ID . As far as I like to use the timestamp from Google Server to indicate the order of orders, it seems that the timestamps between GAE servers may differ from your requirement.
Add your tasks to Pull Queue instead of Push Queue . when creating TaskOption , add the ID obtained from step # 1 as tag . After adding the task, save the ID somewhere in your data warehouse.
Your working servlet rents Tasks for a specific tag from Pull Queue . Query the data store to get the earliest identifier to retrieve, and use the ID as a rental tag . This way you can model the FIFO behavior for your task queue.
Once processing is complete, delete the ID from your data store and remember to also remove Task from your Pull Queue . In addition, I would recommend you complete your backend tasks.
UPDATE: As Nick Johnson and mjaggard noted, the outline in step # 1 seems to be impractical to generate monotonically increasing identifiers, and then other sources of identifiers will be needed. I seem to recall that you used timestamps created by your vehicles, can this be used instead of a monotonously increasing identifier?
Regardless of how identifiers are generated, the main idea is to use the data warehouse query mechanism to create a FIFO Tasks order and use the tag task to pull a specific task from the TaskQueue .
However, there is a reservation. Due to the consistency policy in high replication datastores, if you selected HRD as your datastore (and you must have M / S deprecated since April 4, 2012), there may be some outdated data returned by the query in step # 2 .
Ibrahim arief
source share