Defining events with records issue

Since events are not changeable, I use records to define events. I send created events to generate aggregates, and this works; however, when I attempt to use another event to change the aggregate’s variable, the variable is found to be empty. Could there be an issue with the record’s serialization? or something else?

Can you share a bit of code please? There might be something wrong in the aggregate. What configuration is used for the event seeializer? Do you have a stacktrace of what is going wrong?

My apologies, it was my mistake. I had set a breakpoint in the event handler method, and when it first hits the breakpoint, the properties in the aggregate are naturally empty (because the framework would replay events)! :joy:`/**
* org id
private Long orgId;
* org permissions
private List productPermission = Lists.newArrayList();

public OrgPermissionAggregate(CreateOrgProductPermissionCommand command, MetaData metaData){
    apply(new OrgProductPermissionCreatedEvent(command.getOrgId()),metaData);

public void on(OrgProductPermissionCreatedEvent event, MetaData metaData){
    this.orgId = event.orgId();

public void handler(AddOrgProductPermissionCommand command,MetaData metaData){
    apply(new OrgProductPermissionAddedEvent(command.getOrgId(),command.getProductIds()),metaData);

public void on(OrgProductPermissionAddedEvent event, MetaData metaData){
    event.productIds().forEach(e -> this.productPermission
            .add(new ProductPermissionV(e,PermissionStatus.ABLE.getCode(),null)));
1 Like