@brabo-hi wrote:
On akka persistence, when receiving a command, how can we execute asynchronous function to validate the command before deciding to reject the command of to persist an event?
EventSourcedBehavior accepts:
commandHandler: (State, Command) => ReplyEffect[Event, State]
I would like to do something like:
val validateCommand(command: Command): Future[Boolean] commandHandler: (State, Command) => validateCommand(command).map(boolean => if(boolean) Effect.reply(replyTo)(Rejected("reason")) else Effect.persist(MyEvent()).thenReply(reply)(_ => Accepted) )
Posts: 1
Participants: 1