let us assume that I have an entity of kind Employee with following properties and initial values:
Employee{Name : "Baqir", employeeID: "1234", requestID: "123456" , status : "INITIATED"}
Please note that I can not use query by entity key to obtain strong consistent results because for this case we do not have entity key.
from app engine backend we have integrated firebase to send notifications to employees. when notification arrived on employee's android phone , our android app hit rest endpoint1 using android background service to update the status from INITIATED to DELIVERED. when employee click on notification our android app opens android camera and capture employees front face and send compressed image to server using REST endpoint2. There is another endpoint3 which saves the high quality of same captured facial image using android background service.
REST Endpoint 1 :
1- load the entity using filter(employeeID) and filter(requestID) 2- update the status to DELIVERED 3- save the entity 4- send the success result to android client.
updated entity from endpoint1 should be like:
Employee{Name : "Baqir", employeeID: "1234", requestID: "123456" , status : "DELIVERED"}
REST Endpoint2: 1- load the entity using filter(employeeID) and filter(requestID) 2- store the captured face to cloud storage and save the download URL. 3-update the status to "COMPLETED" 4- save the entity 5- send the success result to android client
updated entity from endpoint2 should be like:
Employee{Name : "Baqir", employeeID: "1234", profilePic: " cloud storage download URL",requestID: "123456" , status : "COMPLETED"}
REST Endpoint3: 1- load the entity using filter(employeeID) and filter(requestID) 2- store the captured face high quality image to cloud storage and save the download URL. 4- save the entity 5- send the success result to android client
updated entity from endpoint3 should be like:
Employee{Name : "Baqir", employeeID: "1234", profilePic: " cloud storage download URL", HQprofilePic: " cloud storage download URL", requestID: "123456" , status : "COMPLETED"}
Problem: Android client always executes endpoint1 first then endpoint2 then endpoint3 and receives success result from all the endpoints. But sometimes the final updated entity in datastore is the entity updated by endpoint1.
After executing endpoint 1,2,3, final entity in the datastore is :
Employee{Name : "Baqir", employeeID: "1234", requestID: "123456" , status : "DELIVERED"}
for some cases final entity is the result of endpoint1 and endpoint3. i.e
Employee{Name : "Baqir", employeeID: "1234", requestID: "123456" , HQprofilePic: " cloud storage download URL", status : "DELIVERED"}