public void appendSnapshotEvent(String type, DomainEventMessage snapshotEvent) {
EntityManager entityManager = entityManagerProvider.getEntityManager();
// Persist snapshot before pruning redundant archived ones, in order to prevent snapshot misses when reloading
// an aggregate, which may occur when a READ_UNCOMMITTED transaction isolation level is used.
final Class<?> dataType = eventEntryStore.getDataType();
SerializedObject serializedPayload = serializer.serializePayload(snapshotEvent, dataType);
SerializedObject serializedMetaData = serializer.serializeMetaData(snapshotEvent, dataType);
try {
eventEntryStore.persistSnapshot(type, snapshotEvent, serializedPayload, serializedMetaData, entityManager);
if (maxSnapshotsArchived > 0) {
eventEntryStore.pruneSnapshots(type, snapshotEvent, maxSnapshotsArchived,
entityManagerProvider.getEntityManager());