What is the id set to in your CounterCreateCommand?
Can you publish two CounterCreateCommands with identical id’s, or is the ‘issuing of multiple commands’ you refer to creating a CounterCreateCommand with unique ids?
As far as I know, that should result in an exception when your CounterCreatedEvent is trying to be stored, because you’d try storing a second CounterCreatedEvent with an identical aggregate identifier and sequence number.
it seems you’re using the InMemoryEventStorageEngine. That one (for some reason) doesn’t check for uniqueness. It just adds all published events to a list.
You’re better off using the JpaEventStorageEngine with an InMemory database if you want to be “production compatible”.
Thanks Allard. I am actually using the MongoEventStorageEngine
new MongoEventStorageEngine(new DefaultMongoTemplate(new MongoClient("10.128.75.101"), "axonframework", "domainevents", "snapshotevents"))
but with the same result. The Mongo is v3.4 just fresh install. Anyway atm I will move away from mongo in favour of couchbase. I can see that this is solved in AbstractEventStorageEngine by the datastore throwing an exception and being handled properly.
are the indexes in place? There should be a unique index on the aggregateIdentifier and sequenceNumber properties. If there isn’t, you can create it by calling “ensureIndexes” on your MongoEventStorageEngine instance.