Package org.axonframework.domain

Examples of org.axonframework.domain.GenericDomainEventMessage


        eventStore.setUpcasterChain(new LazyUpcasterChain(serializer,
                                                          Collections.<Upcaster>singletonList(new ToDoItemUpcaster())));

        // we append some events. Notice we append a "ToDoItemCreatedEvent".
        eventStore.appendEvents("UpcasterSample", new SimpleDomainEventStream(
                new GenericDomainEventMessage("todo1", 0, new ToDoItemCreatedEvent("todo1", "I need to do this today")),
                new GenericDomainEventMessage("todo1", 1, new ToDoItemCompletedEvent("todo1"))
        ));
        eventStore.appendEvents("UpcasterSample", new SimpleDomainEventStream(
                new GenericDomainEventMessage("todo2", 0, new ToDoItemCreatedEvent("todo2", "I also need to do this"))
        ));

        // now, we read the events from the "todo1" stream
        DomainEventStream eventStream = eventStore.readEvents("UpcasterSample", "todo1");
        while (eventStream.hasNext()) {
View Full Code Here


        // we fetch the EventStore from the application context
        EventStore eventStore = applicationContext.getBean(EventStore.class);

        // we append some events. Notice we append a "ToDoItemCreatedEvent".
        eventStore.appendEvents("UpcasterSample", new SimpleDomainEventStream(
                new GenericDomainEventMessage("todo1", 0, new ToDoItemCreatedEvent("todo1", "I need to do this today")),
                new GenericDomainEventMessage("todo1", 1, new ToDoItemCompletedEvent("todo1"))
        ));
        eventStore.appendEvents("UpcasterSample", new SimpleDomainEventStream(
                new GenericDomainEventMessage("todo2", 0, new ToDoItemCreatedEvent("todo2", "I also need to do this"))
        ));


        // now, we read the events from the "todo1" stream
        DomainEventStream upcastEvents = eventStore.readEvents("UpcasterSample", "todo1");
View Full Code Here

    @DirtiesContext
    @Test
    public void testVisitAllEvents_IncludesUnknownEventType() throws Exception {
        EventVisitor eventVisitor = mock(EventVisitor.class);
        testSubject.appendEvents("test", new SimpleDomainEventStream(createDomainEvents(10)));
        final GenericDomainEventMessage eventMessage = new GenericDomainEventMessage<String>("test", 0, "test");
        testSubject.appendEvents("test", new SimpleDomainEventStream(eventMessage));
        testSubject.appendEvents("test", new SimpleDomainEventStream(createDomainEvents(10)));
        // we upcast the event to two instances, one of which is an unknown class
        testSubject.setUpcasterChain(new LazyUpcasterChain(Arrays.<Upcaster>asList(new StubUpcaster())));
        testSubject.visitEvents(eventVisitor);
View Full Code Here

            @Override
            protected void doInTransactionWithoutResult(
                    TransactionStatus status) {
                DomainEventMessage firstEvent = aggregate2.getUncommittedEvents().next();
                entityManager.persist(new DomainEventEntry("type",
                                                           new GenericDomainEventMessage(
                                                                   "a",
                                                                   new DateTime(),
                                                                   "someValue",
                                                                   0,
                                                                   "",
                                                                   MetaData.emptyInstance()),
                                                           emptySerializedObject,
                                                           emptySerializedObject));
            }
        });
        template.execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(
                    TransactionStatus status) {
                entityManager.persist(new DomainEventEntry("type",
                                                           new GenericDomainEventMessage(
                                                                   "a",
                                                                   new DateTime(),
                                                                   "anotherValue",
                                                                   0,
                                                                   "",
View Full Code Here

    @Test
    @Transactional
    public void testVisitAllEvents_IncludesUnknownEventType() throws Exception {
        EventVisitor eventVisitor = mock(EventVisitor.class);
        testSubject.appendEvents("test", new SimpleDomainEventStream(createDomainEvents(10)));
        final GenericDomainEventMessage eventMessage = new GenericDomainEventMessage<String>("test", 0, "test");
        testSubject.appendEvents("test", new SimpleDomainEventStream(eventMessage));
        testSubject.appendEvents("test", new SimpleDomainEventStream(createDomainEvents(10)));
        // we upcast the event to two instances, one of which is an unknown class
        testSubject.setUpcasterChain(new LazyUpcasterChain(Arrays.<Upcaster>asList(new StubUpcaster())));
        testSubject.visitEvents(eventVisitor);
View Full Code Here

        final ExecutorService executor = Executors.newFixedThreadPool(2);
        snapshotter.setAggregateFactories(Arrays.<AggregateFactory<?>>asList(new GenericAggregateFactory<StubAggregate>(StubAggregate.class)));
        new TransactionTemplate(transactionManager).execute(new TransactionCallbackWithoutResult() {
            @Override
            protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) {
                eventStore.appendEvents("StubAggregate", new SimpleDomainEventStream(new GenericDomainEventMessage("id1", 0, "Payload1"),
                                                                                     new GenericDomainEventMessage("id1", 1, "Payload2")));
            }
        });
        try {
            snapshotter.setExecutor(executor);
            snapshotter.scheduleSnapshot("StubAggregate", "id1");
View Full Code Here

    }

    @Test
    public void fetchAggregateStreamShouldWork() throws SQLException {
        deleteCurrentPersistentEvents();
        DomainEventMessage first = new GenericDomainEventMessage(aggregateIdentifier, 122, "apayload");
        testSubject.persistEvent(aggregateType, first, getPayload(), getMetaData());
        DomainEventMessage second = new GenericDomainEventMessage(aggregateIdentifier, 123, "apayload2");
        testSubject.persistEvent(aggregateType, second, getPayload(), getMetaData());

        final Iterator<? extends SerializedDomainEventData> actual = testSubject.fetchAggregateStream(aggregateType, aggregateIdentifier, 1, 1);

        checkSame(first, actual.next());
View Full Code Here

    }

    @Test
    public void fetchAggregateStreamWorks() throws SQLException {
        deleteCurrentPersistentEvents();
        DomainEventMessage dem = new GenericDomainEventMessage(aggregateIdentifier, 122, "apayload");
        testSubject.persistEvent(aggregateType, dem, getPayload(), getMetaData());
        DomainEventMessage dem2 = new GenericDomainEventMessage(aggregateIdentifier, 123, "apayload2");
        testSubject.persistEvent(aggregateType, dem2, getPayload(), getMetaData());

        Iterator<? extends SerializedDomainEventData> stream = testSubject.fetchAggregateStream(aggregateType, "agg1", 0, 1);
        assertTrue(stream.hasNext());
        SerializedDomainEventData next = stream.next();
        assertEquals(dem.getSequenceNumber(), next.getSequenceNumber());
        assertTrue(stream.hasNext());
        SerializedDomainEventData next1 = stream.next();
        assertEquals(dem2.getSequenceNumber(), next1.getSequenceNumber());
        assertFalse(stream.hasNext());
    }
View Full Code Here

    }

    @Test
    public void persistSnapshots() throws SQLException {
        deleteCurrentSnapshotEvents();
        DomainEventMessage dem = new GenericDomainEventMessage(aggregateIdentifier, 122, "apayload");
        testSubject.persistSnapshot(snap_aggregateType, dem, getPayload(), getMetaData());
        DomainEventMessage expected = new GenericDomainEventMessage(aggregateIdentifier, 123, "apayload2");
        testSubject.persistSnapshot(snap_aggregateType, expected, getPayload(), getMetaData());

        final SerializedDomainEventData actual = testSubject.loadLastSnapshotEvent(snap_aggregateType, "agg1");
        checkSame(expected, actual);
    }
View Full Code Here

    }

    @Test
    public void pruneSnapshots() throws SQLException {
        deleteCurrentSnapshotEvents();
        DomainEventMessage dem = new GenericDomainEventMessage(aggregateIdentifier, 122, "apayload");
        testSubject.persistSnapshot(snap_aggregateType, dem, getPayload(), getMetaData());
        DomainEventMessage expected = new GenericDomainEventMessage(aggregateIdentifier, 123, "apayload2");
        testSubject.persistSnapshot(snap_aggregateType, expected, getPayload(), getMetaData());

        testSubject.pruneSnapshots(snap_aggregateType, expected, 1);
        ResultSet resultSet = connection.prepareStatement("select count(*) from SnapshotEventEntry").executeQuery();
        resultSet.next();
View Full Code Here

TOP

Related Classes of org.axonframework.domain.GenericDomainEventMessage

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.