Package org.axonframework.repository

Examples of org.axonframework.repository.ConcurrencyException


        jedis.watch(key);
        Long eventCount = jedis.llen(key);
        if ((firstEvent.getSequenceNumber() != 0 && eventCount == null)
                || firstEvent.getSequenceNumber() != eventCount) {
            jedis.unwatch();
            throw new ConcurrencyException(
                    String.format("Concurrent modification detected for Aggregate identifier [%s], sequence: [%s]",
                                  firstEvent.getAggregateIdentifier(),
                                  firstEvent.getSequenceNumber()));
        }
View Full Code Here


            entityManager.flush();
        } catch (RuntimeException exception) {
            if (event != null
                    && persistenceExceptionResolver != null
                    && persistenceExceptionResolver.isDuplicateKeyViolation(exception)) {
                throw new ConcurrencyException(
                        String.format("Concurrent modification detected for Aggregate identifier [%s], sequence: [%s]",
                                      event.getAggregateIdentifier(),
                                      event.getSequenceNumber()),
                        exception);
            }
View Full Code Here

            entityManager.flush();
        } catch (RuntimeException exception) {
            if (snapshotEvent != null
                    && persistenceExceptionResolver != null
                    && persistenceExceptionResolver.isDuplicateKeyViolation(exception)) {
                throw new ConcurrencyException(
                        String.format("A snapshot for aggregate [%s] at sequence: [%s] was already inserted",
                                      snapshotEvent.getAggregateIdentifier(),
                                      snapshotEvent.getSequenceNumber()),
                        exception);
            }
View Full Code Here

            }
        } catch (RuntimeException exception) {
            if (persistenceExceptionResolver != null
                    && persistenceExceptionResolver.isDuplicateKeyViolation(exception)) {
                //noinspection ConstantConditions
                throw new ConcurrencyException(
                        String.format("Concurrent modification detected for Aggregate identifier [%s], sequence: [%s]",
                                      event.getAggregateIdentifier(),
                                      event.getSequenceNumber()),
                        exception
                );
View Full Code Here

            eventEntryStore.persistSnapshot(type, snapshotEvent, serializedPayload, serializedMetaData);
        } catch (RuntimeException exception) {
            if (persistenceExceptionResolver != null
                    && persistenceExceptionResolver.isDuplicateKeyViolation(exception)) {
                //noinspection ConstantConditions
                throw new ConcurrencyException(
                        String.format("A snapshot for aggregate [%s] at sequence: [%s] was already inserted",
                                      snapshotEvent.getAggregateIdentifier(),
                                      snapshotEvent.getSequenceNumber()),
                        exception
                );
View Full Code Here

        try {
            mongoTemplate.domainEventCollection().insert(storageStrategy.createDocuments(type,
                                                                                         eventSerializer,
                                                                                         messages));
        } catch (MongoException.DuplicateKey e) {
            throw new ConcurrencyException("Trying to insert an Event for an aggregate with a sequence "
                                                   + "number that is already present in the Event Store", e);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("{} events appended", new Object[]{messages.size()});
View Full Code Here

        final DBObject dbObject = storageStrategy.createDocuments(type, eventSerializer,
                                                                  Collections.singletonList(snapshotEvent))[0];
        try {
            mongoTemplate.snapshotEventCollection().insert(dbObject);
        } catch (MongoException.DuplicateKey e) {
            throw new ConcurrencyException("Trying to insert a SnapshotEvent with aggregate identifier and sequence "
                                                   + "number that is already present in the Event Store", e);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("snapshot event of type {} appended.");
        }
View Full Code Here

    @Test
    public void testScheduleSnapshot_ConcurrencyExceptionIsSilenced()
            throws NoSuchFieldException, IllegalAccessException {
        final Object aggregateIdentifier = "aggregateIdentifier";
        doNothing()
                .doThrow(new ConcurrencyException("Mock"))
                .when(mockEventStore).appendSnapshotEvent(eq("test"), isA(DomainEventMessage.class));
        when(mockEventStore.readEvents("test", aggregateIdentifier))
                .thenAnswer(new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
View Full Code Here

    // trigger retry
        commandBus.subscribe(String.class.getName(), new CommandHandler<String>() {
            @Override
            public Object handle(CommandMessage<String> commandMessage, UnitOfWork unitOfWork) throws Throwable {
                throw new ConcurrencyException("some retryable exception");
            }
        });

        // say we have a dispatch interceptor that expects to get the user's session from a ThreadLocal...
        // yes, this should be configured on the gateway instead of the command bus, but still...
View Full Code Here

      // trigger retry, then return metadata for verification
        commandBus.subscribe(String.class.getName(), new CommandHandler<String>() {
            @Override
            public MetaData handle(CommandMessage<String> commandMessage, UnitOfWork unitOfWork) throws Throwable {
              if (Thread.currentThread() == testThread) {
                throw new ConcurrencyException("some retryable exception");
              } else {
                return commandMessage.getMetaData();
              }
            }
        });
View Full Code Here

TOP

Related Classes of org.axonframework.repository.ConcurrencyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.