Multiple command handling in the same transaction

To process multiple commands at once, you should use batchProcessCommand method. Commands will be process in the same transaction, therefore if one command fail, events derived from the other won’t be written / published.

Code below show implementation of multiple command processing to transfer money from one account to another in the same transaction, see complete code here.

        new BankCommand.Withdraw(transferDTO.from, transferDTO.amount),
        new BankCommand.Deposit(, transferDTO.amount))
    .map(either -> either.fold(
        errors -> new ResponseEntity<TransferResultDTO>(TransferResultDTO.error(String.join("\n", errors)), HttpStatus.BAD_REQUEST),
        success -> {
            var fromResult = success.get(0);
            var toResult = success.get(1);
            return ResponseEntity.ok(new TransferResultDTO(
The source code for this page can be found here.