Search in sources :

Example 1 with InvalidPositionException

use of uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidPositionException in project microservice_framework by CJSCommonPlatform.

the class DefaultEventRepository method storeEvent.

@Override
@Transactional(dontRollbackOn = OptimisticLockingRetryException.class)
public void storeEvent(final JsonEnvelope envelope) throws StoreEventRequestFailedException {
    try {
        final Event event = eventConverter.eventOf(envelope);
        logger.trace("Storing event {} into stream {} at position {}", event.getName(), event.getStreamId(), event.getSequenceId());
        eventJdbcRepository.insert(event);
    } catch (InvalidPositionException ex) {
        throw new StoreEventRequestFailedException(String.format("Could not store event for position %d of stream %s", envelope.metadata().position().orElse(null), envelope.metadata().streamId().orElse(null)), ex);
    }
}
Also used : StoreEventRequestFailedException(uk.gov.justice.services.eventsourcing.repository.jdbc.exception.StoreEventRequestFailedException) Event(uk.gov.justice.services.eventsourcing.repository.jdbc.event.Event) InvalidPositionException(uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidPositionException) Transactional(javax.transaction.Transactional)

Aggregations

Transactional (javax.transaction.Transactional)1 Event (uk.gov.justice.services.eventsourcing.repository.jdbc.event.Event)1 InvalidPositionException (uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidPositionException)1 StoreEventRequestFailedException (uk.gov.justice.services.eventsourcing.repository.jdbc.exception.StoreEventRequestFailedException)1