Package org.axonframework.unitofwork

Examples of org.axonframework.unitofwork.UnitOfWork.commit()


                    (UnitOfWorkFactory) context.getScheduler().getContext().get(UNIT_OF_WORK_FACTORY_KEY);
            UnitOfWork uow = unitOfWorkFactory.createUnitOfWork();
            try {
                uow.publishEvent(eventMessage, eventBus);
            } finally {
                uow.commit();
            }
            if (logger.isInfoEnabled()) {
                logger.info("Job successfully executed. Scheduled Event [{}] has been published.",
                            eventMessage.getPayloadType().getSimpleName());
            }
View Full Code Here


        UnitOfWork uow = DefaultUnitOfWork.startAndGet(new SpringTransactionManager(transactionManager));
        Connection connection = connectionProvider.getConnection();

        connection.commit();

        uow.commit();
    }

    @Test
    public void testConnectionCommittedWhenTransactionScopeInsideUnitOfWork() throws Exception {
        doAnswer(new Answer<Object>() {
View Full Code Here

        assertNotSame(connection, mockConnection);

        connection.commit();
        verify(mockConnection, never()).commit();

        uow.commit();
        verify(mockConnection).commit();
    }

    @ImportResource("classpath:/META-INF/spring/db-context.xml")
    @Configuration
View Full Code Here

        eventBus.subscribe(new CommandExecutingEventListener("1", null, true));
        eventBus.subscribe(new CommandExecutingEventListener("2", null, true));

        UnitOfWork uow = uowFactory.createUnitOfWork();
        repository.add(new Aggregate(id));
        uow.commit();

        Aggregate verify = loadAggregate(id);
        assertEquals(2, verify.tokens.size());
        assertTrue(verify.tokens.containsAll(asList("1", "2")));
    }
View Full Code Here

        Aggregate a = new Aggregate(id);

        // First command: Create Aggregate
        UnitOfWork uow1 = uowFactory.createUnitOfWork();
        repository.add(a);
        uow1.commit();

        Aggregate verify = loadAggregate(id);

        assertEquals(id, verify.id);
        assertEquals(7, verify.tokens.size());
View Full Code Here

                AggregateCreatedEvent created = (AggregateCreatedEvent) payload;

                UnitOfWork nested = uowFactory.createUnitOfWork();
                Aggregate aggregate = repository.load(created.id);
                aggregate.update(token);
                nested.commit();
            }

            if (previousToken != null && payload instanceof AggregateUpdatedEvent) {
                AggregateUpdatedEvent updated = (AggregateUpdatedEvent) payload;
                if (updated.token.equals(previousToken)) {
View Full Code Here

                if (updated.token.equals(previousToken)) {
                    UnitOfWork nested = uowFactory.createUnitOfWork();
                    Aggregate aggregate = repository.load(updated.id);
                    aggregate.update(token);
                    if (commit) {
                        nested.commit();
                    } else {
                        nested.rollback();
                    }
                }
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.