[axonframework] Designing Command with complex strcutures

Currently scenario I have is Create an Organisation with an Office. Ideally I would like them to be split into two commands CreateOfficeCommand and AddOfficeCommand. How can I associated AddOfficeCommand to the same aggregate as CreateOfficeCommand. Shall I use aggregateId generation on the client side?

Something like this, ignore identifiedFactory

@RequestMapping(method= RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public void post(@RequestBody @Valid CreateGroupRequest request) {
    String identifier = identifierFactory.generateIdentifier();
    CreateGroupCommand createGroupCommand = new CreateGroupCommand(identifier,
                                                                request.getName(),
                                                                request.getUrl(),
                                                                request.getNotes(),
                                                                request.getSortName(),
                                                                request.isInactive(),
                                                                request.getUserKey(),
                                                                request.getType());

    this.commandGateway.send(createGroupCommand);

    AddOfficeCommand addOfficeCommand = new AddOfficeCommand(request.getOffices());
    this.commandGateway.send(addOfficeCommand);

}

Hi,

this solution looks allright. Generating ids on the client side (i.e. the sending side of the command bus) is a good practice.

Cheers,

Allard