@Test public void testAppendEventsIsPerformedInATransaction() { testSubject.appendEvents(createEvents(2)); verify(transactionManager).executeInTransaction(any()); }
@Override protected void appendEvents(List<? extends EventMessage<?>> events, Serializer serializer) { if (events.isEmpty()) { return; } transactionManager.executeInTransaction(() -> { try { events.stream().map(event -> createEventEntity(event, serializer)).forEach(entityManager()::persist); if (explicitFlush) { entityManager().flush(); } } catch (Exception e) { handlePersistenceException(e, events.get(0)); } }); }
JpaEventStorageEngine extends BatchingEventStorageEngine { @Override protected void appendEvents(List<? extends EventMessage<?>> events, Serializer serializer) { if (events.isEmpty()) { return; } transactionManager.executeInTransaction(() -> { try { events.stream().map(event -> createEventEntity(event, serializer)).forEach(entityManager()::persist); if (explicitFlush) { entityManager().flush(); } } catch (Exception e) { handlePersistenceException(e, events.get(0)); } }); } }
JpaEventStorageEngine extends BatchingEventStorageEngine { @Override protected void appendEvents(List<? extends EventMessage<?>> events, Serializer serializer) { if (events.isEmpty()) { return; } transactionManager.executeInTransaction(() -> { try { events.stream().map(event -> createEventEntity(event, serializer)).forEach(entityManager()::persist); if (explicitFlush) { entityManager().flush(); } } catch (Exception e) { handlePersistenceException(e, events.get(0)); } }); } protected  JpaEventStorageEngine(Builder builder); }
JpaEventStorageEngine extends BatchingEventStorageEngine { @Override protected void appendEvents(List<? extends EventMessage<?>> events, Serializer serializer) { if (events.isEmpty()) { return; } transactionManager.executeInTransaction(() -> { try { events.stream().map(event -> createEventEntity(event, serializer)).forEach(entityManager()::persist); if (explicitFlush) { entityManager().flush(); } } catch (Exception e) { handlePersistenceException(e, events.get(0)); } }); } protected  JpaEventStorageEngine(Builder builder); static Builder builder(); @Override Optional<Long> lastSequenceNumberFor(String aggregateIdentifier); @Override TrackingToken createTailToken(); @Override TrackingToken createHeadToken(); @Override TrackingToken createTokenAt(Instant dateTime); void setGapTimeout(int gapTimeout); void setGapCleaningThreshold(int gapCleaningThreshold); }
JpaEventStorageEngine extends BatchingEventStorageEngine { @Override protected void appendEvents(List<? extends EventMessage<?>> events, Serializer serializer) { if (events.isEmpty()) { return; } transactionManager.executeInTransaction(() -> { try { events.stream().map(event -> createEventEntity(event, serializer)).forEach(entityManager()::persist); if (explicitFlush) { entityManager().flush(); } } catch (Exception e) { handlePersistenceException(e, events.get(0)); } }); } protected  JpaEventStorageEngine(Builder builder); static Builder builder(); @Override Optional<Long> lastSequenceNumberFor(String aggregateIdentifier); @Override TrackingToken createTailToken(); @Override TrackingToken createHeadToken(); @Override TrackingToken createTokenAt(Instant dateTime); void setGapTimeout(int gapTimeout); void setGapCleaningThreshold(int gapCleaningThreshold);  }