I think the key point here is how long a “long computation” is.
Considering that a
PersistentEntity is the equivalent of an
Aggregate in DDD parlance, a command handler should only operate on the data available at hand, which can only be the data passed in the command and the state of the Entity itself.
How long can such a computation be?
If an Entity is fulfilling its duty of being the guardian of the consistency of a domain model, then it only operates on data that is already in memory and in scope. There should be no IO or remote calls inside an Entity because that would mean that it’s not in possession of the data it’s supposed to guard against inconsistencies.
In any case, if there is such a heavy computation (that still only operates on data in scope), you can always increase the timeout of an
Moreover, and I know that this is an unpopular topic, there is no async command handlers in Lagom for the reasons I just mentioned. That said, one needs to call blocking APIs if they want to do really heavy computations. And again, that will be against the basic principles of aggregate design.