Package org.axonframework.domain

Examples of org.axonframework.domain.DomainEventMessage


    @SuppressWarnings({"unchecked"})
    @Override
    public DomainEventStream readEvents(String type, Object identifier) {
        long snapshotSequenceNumber = -1;
        SerializedDomainEventData lastSnapshotEvent = eventEntryStore.loadLastSnapshotEvent(type, identifier);
        DomainEventMessage snapshotEvent = null;
        if (lastSnapshotEvent != null) {
            try {
                snapshotEvent = new GenericDomainEventMessage<Object>(
                        identifier,
                        lastSnapshotEvent.getSequenceNumber(),
                        serializer.deserialize(lastSnapshotEvent.getPayload()),
                        (Map<String, Object>) serializer.deserialize(lastSnapshotEvent.getMetaData()));
                snapshotSequenceNumber = snapshotEvent.getSequenceNumber();
            } catch (RuntimeException ex) {
                logger.warn("Error while reading snapshot event entry. "
                                    + "Reconstructing aggregate on entire event stream. Caused by: {} {}",
                            ex.getClass().getName(),
                            ex.getMessage()
View Full Code Here


     * @return The latest snapshot of the given aggregate identifier
     *
     * @throws IOException when reading the <code>snapshotEventFile</code> or reading the <code>eventFile</code> failed
     */
    public DomainEventMessage readSnapshotEvent(String type, Object identifier) throws IOException {
        DomainEventMessage snapshotEvent = null;

        FileSystemSnapshotEventEntry fileSystemSnapshotEvent = readLastSnapshotEntry();
        if(fileSystemSnapshotEvent != null) {
            long actuallySkipped = eventFile.skip(fileSystemSnapshotEvent.getBytesToSkipInEventFile());
            if (actuallySkipped != fileSystemSnapshotEvent.getBytesToSkipInEventFile()) {
View Full Code Here

            return next != null && next.getSequenceNumber() <= lastSequenceNumber;
        }

        @Override
        public DomainEventMessage next() {
            DomainEventMessage current = next;
            initializeNextItem();
            return current;
        }
View Full Code Here

        testSubject.appendEvents("test", aggregate2.getUncommittedEvents());
        DomainEventStream events = testSubject.readEvents("test", aggregate1.getIdentifier());
        List<DomainEventMessage> actualEvents = new ArrayList<DomainEventMessage>();
        long expectedSequenceNumber = 0L;
        while (events.hasNext()) {
            DomainEventMessage event = events.next();
            // Tests AXON-169
            assertNotNull(event.getIdentifier());
            actualEvents.add(event);
            assertEquals("Events are read back in in the wrong order",
                         expectedSequenceNumber,
                         event.getSequenceNumber());
            expectedSequenceNumber++;
        }
        assertEquals(aggregate1.getUncommittedEventCount(), actualEvents.size());
    }
View Full Code Here

// --------------------- Interface EventStore ---------------------

    @Override
    public void appendEvents(String type, DomainEventStream events) {
        while (events.hasNext()) {
            DomainEventMessage event = events.next();
            write(event.getSequenceNumber(), event, eventTemplate);
        }
    }
View Full Code Here

    @Override
    public DomainEventStream readEvents(String type, Object identifier) {
        String rowKey = identifier.toString();
        DomainEventStream snapshotStream = read(rowKey, snapshotCFName, null);
        DomainEventMessage snapshot = null;
        if (snapshotStream.hasNext()) {
            snapshot = snapshotStream.next();
        }
        return read(rowKey, eventCFName, snapshot);
    }
View Full Code Here

        testSubject.appendEvents("test", aggregate2.getUncommittedEvents());
        DomainEventStream events = testSubject.readEvents("test", aggregate1.getIdentifier());
        List<DomainEventMessage> actualEvents = new ArrayList<DomainEventMessage>();
        long expectedSequenceNumber = 0L;
        while (events.hasNext()) {
            DomainEventMessage event = events.next();
            actualEvents.add(event);
            assertEquals("Events are read back in in the wrong order",
                         expectedSequenceNumber,
                         event.getSequenceNumber());
            expectedSequenceNumber++;
        }
        assertEquals(aggregate1.getUncommittedEventCount(), actualEvents.size());
    }
View Full Code Here

                                                      Collections.singletonMap("key", (Object) "Value"))));

        DomainEventStream events = testSubject.readEvents("test", aggregate1.getIdentifier());
        List<DomainEventMessage> actualEvents = new ArrayList<DomainEventMessage>();
        while (events.hasNext()) {
            DomainEventMessage event = events.next();
            event.getPayload();
            event.getMetaData();
            actualEvents.add(event);
        }

        assertEquals(20, actualEvents.size());
        for (int t = 0; t < 20; t = t + 2) {
View Full Code Here

            return next != null;
        }

        @Override
        public DomainEventMessage next() {
            DomainEventMessage retValue = next;
            readNext();
            return retValue;
        }
View Full Code Here

        }

        DomainEventStream committedEvents = eventStore.readEvents("SimpleAggregateRoot", aggregateIdentifier);
        long lastSequenceNumber = -1;
        while (committedEvents.hasNext()) {
            DomainEventMessage nextEvent = committedEvents.next();
            assertEquals("Events are not stored sequentially. Most likely due to unlocked concurrent access.",
                         ++lastSequenceNumber,
                         nextEvent.getSequenceNumber());
        }
        return lastSequenceNumber;
    }
View Full Code Here

TOP

Related Classes of org.axonframework.domain.DomainEventMessage

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.