Process Manager used for validation and other questions on CQRS ES design

101 views
Skip to first unread message

Denis Mikhaylov

unread,
Jun 22, 2016, 9:10:14 AM6/22/16
to DDD/CQRS
Hi! I need some comments on my draft of the design of a billing system with subscriptions. I use Akka with CQRS/ES library with constraints that AR is Command => *Event, and PM is Event => *Command. So query is only possible on the read side.

I have a sales context which has  Product aggregate which contains different ProductPlans consisting of Phases (e.g. trial, evergreen, etc)
In invoicing and payments context I have a User (or Client or Payer not sure how to name it) which has several PaymentMethods with only one selected as a default
In subscription management system I have a Subscription aggregate

When external system creates a subscription for user it provides me with UserId and specified product plan phase (i.e. productId, planId, phaseType).

1 A SubscriptionProcess:
1.1 Wtarts when SubscriptionCreated -> in order to get billing details (e.g. billing period, price, nextPhaseSpec) issues SettleSubscriptionPlan command to Product
1.2 When SubscriptionPlanSettled -> issues ActivateSubscription command to Subscription

In payment context:

2 A SubscriptionInvoicingProcess:
2.1 Starts when SubscriptionCreated -> just updates the state
2.2 When SubscriptionPlanSettled -> issues CreateInvoice with payment details
2.3 When InvoiceCreated -> issues PurchasePayment to Payer (which interacts with external system based on default PaymentMethod).
2.4 When PaymentSucceed -> issues MarkAsPayed to Invoice

So the questions:
- Is ot ok to use aggregate like I do in 1.1? This will create an event for each subscription + plan changes (expected ~500 000 subscriptions per product).
- Issues PurchasePayment to Payer doesn't seem right however only Payer nows it's default payment method.

emragins

unread,
Jun 24, 2016, 5:35:32 AM6/24/16
to DDD/CQRS
I'm getting the impression you are trying to push/aggregate changes in your aggregates in order to publish the results -- is this correct?

Could this problem be viewed another way: build you read model and when something changes that someone else is interested in, let them respond to your event to get the latest information?

Is that why you started with your "constraints"? couldn't it be:
Command -> aggregate event -> pm responds issues command -> (something else) pulls data?

Sorry, I don't fully understand the problem and I'm operating on way too little sleep, so if the above makes no sense please just ignore.

Reply all
Reply to author
Forward
0 new messages