Hi,
We are using AxonFramework 3.1.1 with Spring Boot 1.5.16.
I would like to retrieve events from EventStore to resend them (through different channels then usually) in case of infrastructure problems or bugs.
We are not using event sourcing, but our aggregates’ state is stored twice:
-
in JPA repository per aggregate (with @Aggregate(repository = “myAggregateRepository”) where myAggregateRepository is GenericJpaRepository)
-
using JpaEventStorageEngine, as list of events in domain_event_entry DB table.
We are using axon-spring-boot-starter to simplify configuration so I simply inject EventStore when I am trying to retrieve events from EventStore like this:
DomainEventStream domainEventStream = eventStore.readEvents('5e9fdeff-acfc-40a0-8e7c-074a733240e8');
EventMessage<?> eventMessage = domainEventStream.next();
However, it is failing with “java.util.NoSuchElementException: No value present” in EventUtils when trying to construct GenericDomainEventMessage, because AggregateType is null. It is indeed not set in database.
Exception:
`
java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:135)
at org.axonframework.eventsourcing.eventstore.EventUtils.lambda$upcastAndDeserializeDomainEvents$1(EventUtils.java:120)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at org.axonframework.eventsourcing.eventstore.BatchingEventStorageEngine$EventStreamSpliterator.tryAdvance(BatchingEventStorageEngine.java:167)
at java.util.stream.StreamSpliterators$WrappingSpliterator.lambda$initPartialTraversalState$222(StreamSpliterators.java:294)
at java.util.stream.StreamSpliterators$AbstractWrappingSpliterator.fillBuffer(StreamSpliterators.java:206)
`
I understand that AggregateType is not set, because we have aggregate repository implemented with GenericJpaRespository and event is stored in DB with AggregateType set to null.
Is there any other way to retrieve event from the database with this type of configuration (when AggregateType is not set)? Another solution would be to store AggregateType - is it possible to configure Axon to do that without event sourcing?
Mariusz