Stateful Actor for two step process – Exception Handling

Client						Play/Akka										Database
	-> createPayment											
													-> save
													<- requiresVerification
								- persistUnverifiedPayment

	<- requiresVerification
// ... waiting for minutes ...
	-> verifyPayment					
								- verifyPayment
													-> save
  1. Two Actors are involved: One for save calls, and one for persistance. The persistance Actor is a child of root, because othwerwise it would die together with the save Actor as soon as the requiresVerification response is sent to the client.

  2. We use the AskOf pattern as a facade from Play to the Actor system.

  3. The verifyPayment operation identifies the persistance Actor using its ActorPath, which is stored in a Cookie.


  • Errors during persistUnverifiedPayment and verifyPayment are not propagated to the client.
    This is because the persistance supervisor does not know who is the asking actor, since its a different one for each operation.

What do you think about this solution, is there a simpler / better way? If not, how can I implement exception propagation to the client with this setup?

What kind of errors from persistUnverifiedPayment and verifyPayment? Exceptions should not be used (at least not thrown) for validation errors or other business logic rejections. Reply with ordinary actor messages.