hello, I am trying to find the best way to pause an actor command and retry it without blocking the actor itselt.
Basically events are filling a hashtable and I need to wait until a specific index of my table is received. So I need to try on a regular basis to see if the array is received but without blocking the actor as it needs to continue to receive other events.
Thanks
Scheduling an internal retry command to the actor itself would be one way to do that. You can find an example in the docs here: Interaction Patterns • Akka Documentation
If you want to defer messages in the meanwhile, that is also possible by stashing them. Stash • Akka Documentation
Hello,
To achieve this, consider using an asynchronous approach. You can utilize a timer or a scheduled task to periodically check the hashtable for the specific index. This way, the actor can continue processing other events without being blocked.
Here’s a simplified example in pseudo-code: Wakeid portal login
pseudo
function checkHashtable():
if hashtable.contains(targetIndex):
process(targetIndex)
else:
schedule next check
// Start initial check without blocking the actor
checkHashtable()
This ensures the actor remains responsive while periodically checking for the desired condition. Hope this helps!
Best Regards,
Peter Philip