MongoEventStorageEngine configuration

Hi All,
Firstly I used axon4.5 and with default configuration created aggregate,commands and events and exposed services as rest apis and invoke some rest calls to store events in default way.Then I changed the storage engine to mongodb engine.

public EventStorageEngine storageEngine(EventUpcasterChain upcasterChain) {
	    return MongoEventStorageEngine.builder()
	        .storageStrategy(new DocumentPerEventStorageStrategy())

When I start the springboot app axon is trying to deserialize object events in the previous eventstorage and throw below error.

Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (byte[])"<><libraryId>1</libraryId><isbn>123460</isbn><title>My Title</title></>"; line: 1, column: 2]
	at com.fasterxml.jackson.core.JsonParser._constructError( ~[jackson-core-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError( ~[jackson-core-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar( ~[jackson-core-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue( ~[jackson-core-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject( ~[jackson-core-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken( ~[jackson-core-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.databind.ObjectReader._initForReading( ~[jackson-databind-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.databind.ObjectReader._bindAndClose( ~[jackson-databind-2.11.4.jar:2.11.4]
	at com.fasterxml.jackson.databind.ObjectReader.readValue( ~[jackson-databind-2.11.4.jar:2.11.4]
	at org.axonframework.serialization.json.JacksonSerializer.deserialize( ~[axon-messaging-4.5.jar:4.5]
	... 25 common frames omitted

How to ensure previous events are not picked by mongodb event sorage engine?

Also I cant see event stored in mongodb for new requests.I can only see emptytracking tokens collection in mongodb?Why events are not storing in mongodb?


After I add below @Bean error went away

public EmbeddedEventStore eventStore(EventStorageEngine storageEngine, AxonConfiguration configuration) {
    return EmbeddedEventStore.builder()
           // .messageMonitor(configuration.messageMonitor(EventStore.class, "eventStore"))

HOwever still I cant see any events stored in mongodb.I can only see emptytracking tokens collection in mongodb?Why events are not storing in mongodb?

Hi Isuru,

Did you have a look at @Ivan_Dugalic repo where he is showing how to configure axon to mongo? GitHub - idugalic/axon-mongo-demo: Axon demo application - MongoDB as an event store


Hi Ben,
After analysing further I found that axon server is the recommended event storage and I decided not to explore further on mongodb event storage since it has very low applicability.

Thanks for your pointers.