Hi David,
I have the same problem and tried to avoid a dispatch interceptor by puting the commandGateway.sendAndWait for my Update-Command into a try-catch. The exceptions is caught and a CreateCommand is send instead. So far, so good. But the event handling afterwards is not behaving as expected: After processing a series of events, only one Event is beeing stored in the EventStore which is a JDBCEventStore. An external EventHandler-Class only gets one of the Events dispatched, so my read model ends up with only one item too… Bit strange.
I’m using Axon 4.1.1. btw.
Would you mind to share your solution?
Here is my code:
UpdateItemOptionBySapStockFileCommand updateCommand = new UpdateItemOptionBySapStockFileCommand(
sapStockFileEntry.getItemOptionId().toString(),
Store.HALDENSLEBEN,
sapStockFileEntry.getStock().intValue(),
sapStockFileEntry.getDeliveryStatementId(),
null, sapStockFileEntry.getTimestamp());
try {
commandGateway.sendAndWait(updateCommand);
} catch (AggregateNotFoundException e) {
CreateItemOptionBySapStockFileCommand createCommand = new CreateItemOptionBySapStockFileCommand(sapStockFileEntry.getItemOptionId().toString(),
Store.HALDENSLEBEN,
sapStockFileEntry.getStock().intValue(),
sapStockFileEntry.getDeliveryStatementId(),
null, sapStockFileEntry.getTimestamp());
commandGateway.sendAndWait(createCommand);
}
Kind regards,
Achim Mahnke