0

I have a microservice called reward. When a customer does a certain activity in a different microservice(spent a specific amount of money), that service publishes an event, lets say SpentRewardingMoney.

In reward service, my aggregate root is Customer.

public class Customer: Entity, IAggregateRoot
{
   // some properties

   public List<CustomerReward> UserRewards { get; private set; } // rewards already given
}

Now in SpentRewardingMoneyConsumer, I have to give reward to that customer.

Problem is, there is some configuration, for simplification suppose a table RewardRule(reward amount, is reward active etc) to disburse reward. According to DDD rule, I have to pull everything through aggregate root but this configuration is not part of aggregate root.

How should I pull this table from the database?.

Moshi
  • 1,385
  • 2
  • 17
  • 36

1 Answers1

0

The rewards can be loaded from a database or any other persistence that you use. It'll be loaded through a repository. The question other part of your question is: Where should it live in your model?

It depends on your ubiquitous language (UL). To my understanding, it sounds like "reward amount" and "is reward active" are all values of the Customer Reward object. (This is an educated guess based on my guess about your requirement and UL).

Rewards could also be it's own aggregate (also depends on UL). In which case communicating between aggregates in the same context is straight forward. You might use a service to simplify the interactions in such a case.

Louis
  • 1,194
  • 1
  • 10
  • 15