1. Do I have to store a domain event promoter?
I think it will be more flexible if you save the promoter as part of the event payload instead of metadata. Security issues should be addressed outside the domain. Not every event occurs by the user, although you can make a fake one for them (SysAdmin for CronJob).
For instance:
ManualPaymentMadeEvent { //store this object as details in your schema amount, by_user//In this case, developers can determine whether store the promoter case by case }
2. What format should I store the type of event?
Should I add a table with event types or are class names enough? Should I add event groups?
I think class names are enough. Adding another table complicates the reading of events (according to connection tables), and I think that it only adds value when class names are renamed (update one row in the event type table). But I think that it does not cause much problems when using
update domain_events set aggregate_type = 'new class name' where aggregate_type = 'origin class name'
I'm not sure I understand event groups, could you add more explanations?
3. What I'm not sure that a domain event can have several restricted contexts or only one, so I have to store event contexts as well?
Events are sometimes used to integrate multiple contexts. But each event occurs in only one context. For example, in the context of ordering, the ManualPaymentMadeEvent function is created and also uses the list of events in the delivery context, considering it as a trigger to start sending.
I prefer to use a database (oracle term) for each user for each context. shipping.domain_events for the delivery context and order.domain_events for the order context.
Here is a diagram in the axon framework that might help
create table DomainEventEntry ( aggregateIdentifier varchar2(255) not null, sequenceNumber number(19,0) not null, type varchar2(255) not null, --aggregate class name eventIdentifier varchar2(255) not null, metaData blob, payload blob not null, -- details payloadRevision varchar2(255), payloadType varchar2(255) not null, --event class name timeStamp varchar2(255) not null ); alter table DomainEventEntry add constraint PK_DomainEventEntry primary key (aggregateIdentifier, sequenceNumber, type);