I have two aggregates: Book and Reader. One reader can borrow up to 3 books. When a read borrows a book, I need to add this book to his borrowed book list, and the same time I need to update the book to save the reader as the current borrower.
The client sends a BorrowCommand
bookCommandGateway.sendAndWait(new BorrowCommand(readerId, req.getBookId()), 3000, TimeUnit.MILLISECONDS);
Both BookEventListener and ReaderEventListener event handlers will handle BorrowEvent.
My question:
-
Is this a good design? Does this count as one command modifies 2 aggregates in a single transaction?
-
How many transactions Axon will execute for this BorrowCommand? One or two? One for aggregate Book and one for aggregate Reader?
(Sorry for the long code followed.)