wonderful world
wonderful world

Reputation: 11599

Validation in AKKA.NET

I have an actor called OrderActor which is the order being created for a customer. I have a validation rule that says If the Product is a computer, allow only one item. This rule should be applied whenever the OrderActor receives a message to add a product.

My question is about the Validation. Should I have a new actor called OrderValidatorActor and this needs to have the OrderActor as the parent actor? In this case, the flow of the events should be The OrderActor sends a message to the OrderValidatorActor which sends a response back to the OrderActor after validation.

Please guide on how to handle validation?

Upvotes: 2

Views: 357

Answers (2)

wonderful world
wonderful world

Reputation: 11599

The role/responsibility based object oriented programming principle apply in actor modeling also. The responsibility of validation is thus done in the OrderValidatorActor.

Upvotes: 1

Terry Lewis
Terry Lewis

Reputation: 407

How about this?

  1. Receive an RequestAddItem message in your OrderActor.
  2. OrderActor sends the item details in a ValidateOrderItem message to OrderValidatorActor.
  3. OrderValidatorActor sends either an AddValidatedItem or DenyInvalidItem message to the OrderActor.

Upvotes: 4

Related Questions