public DomainEventStream readEvents(String type, Object identifier) {
long snapshotSequenceNumber = -1;
EntityManager entityManager = entityManagerProvider.getEntityManager();
SerializedDomainEventData lastSnapshotEvent = eventEntryStore.loadLastSnapshotEvent(type, identifier,
entityManager);
DomainEventMessage snapshotEvent = null;
if (lastSnapshotEvent != null) {
try {
snapshotEvent = new GenericDomainEventMessage<Object>(
identifier,
lastSnapshotEvent.getSequenceNumber(),
serializer.deserialize(lastSnapshotEvent.getPayload()),
(Map<String, Object>) serializer.deserialize(lastSnapshotEvent.getMetaData()));
snapshotSequenceNumber = snapshotEvent.getSequenceNumber();
} catch (RuntimeException ex) {
logger.warn("Error while reading snapshot event entry. "
+ "Reconstructing aggregate on entire event stream. Caused by: {} {}",
ex.getClass().getName(),
ex.getMessage());