Reputation: 2349
Scenerio:
Function A() ->creates the message and puts the message in the queue
Listener -> checks constantly if theres a message in the queue and sends it to the service to process it and get the result and inserts the result into db
Function B() ->gets the result from the db
Suppose the result from the service hasn't come out yet and function b() is called now,the record for tht message id would return null from the db as the result hasnt been inserted yet.
How do you handle such scenerio?
Upvotes: 0
Views: 549
Reputation: 48583
If function B is dependent on the service completing processing, then it should run off a message queue as well.
When the service finishes, it should write a new message to another queue. Another listener should pick it up and call function B.
If function B is initiated by a user interface gesture, the UI just needs to convey that a required process hasn't completed and disallow the action until it does.
Upvotes: 3