I noticed, that in a simple ES example, I only need to place @TargetAggregateIdentifier on commands.
I suspect that I should use it on all messages?
I assume that I would only have to specify that annotation if I publish events on the event gateway. And that I never have to do it for queries.
AFAIK, it’s only required for commands.
Hello sam, the knowledge to which aggregate an event should be routed to is persisted in event’s metadata automatically when you apply an event within your aggregate class.
So yes, as Brian says, it is only required for commands. Well, not really required-required because you can use RoutingStrategy to generate random target aggregate identifier so it will be handled by the command handler that handles such command.