Package org.axonframework.domain

Examples of org.axonframework.domain.EventMessage


        uowFactory = new DefaultUnitOfWorkFactory();
    }

    @Test
    public void testPublishEvent() {
        final EventMessage initialEvent = GenericEventMessage.asEventMessage(new Object());
        final EventMessage secondEvent = GenericEventMessage.asEventMessage(new Object());
        final EventMessage finalEvent = GenericEventMessage.asEventMessage(new Object());

        final EventListener eventListener = spy(new EventListener() {
            @Override
            public void handle(EventMessage event) {
                UnitOfWork inner = uowFactory.createUnitOfWork();
View Full Code Here


        inOrder.verify(eventListener).handle(finalEvent);
    }

    @Test
    public void testEventNotPublishedOnUnitOfWorkRollback() {
        final EventMessage initialEvent = GenericEventMessage.asEventMessage(new Object());
        final EventMessage secondEvent = GenericEventMessage.asEventMessage(new Object());
        final EventMessage finalEvent = GenericEventMessage.asEventMessage(new Object());

        final EventListener eventListener = spy(new EventListener() {
            @Override
            public void handle(EventMessage event) {
                UnitOfWork inner = uowFactory.createUnitOfWork();
View Full Code Here

        verify(eventListener, never()).handle(finalEvent);
    }

    @Test
    public void testPublishEvent_RegistrationListenerOnlyInvokedOncePerEvent() {
        final EventMessage initialEvent = GenericEventMessage.asEventMessage(new Object());
        final EventMessage secondEvent = GenericEventMessage.asEventMessage(new Object());
        final EventMessage finalEvent = GenericEventMessage.asEventMessage(new Object());
        final UnitOfWorkListener mockUoWListener = spy(new UnitOfWorkListenerAdapter() {
        });

        final EventListener eventListener = spy(new EventListener() {
            @Override
View Full Code Here

    }

    @Test
    public void testPublishEvent() {
        testSubject.subscribe(eventListener);
        EventMessage event = new GenericEventMessage<Object>(new Object());
        testSubject.publish(event);

        verify(eventListener).handle(event);
    }
View Full Code Here

    @Override
    public synchronized void processBacklog(Cluster destination) {
        inReplay = false;
        while (!backlog.isEmpty()) {
            EventMessage message = backlog.poll();
            if (message != null && !replayedMessages.contains(message.getIdentifier())) {
                destination.publish(message);
            }
        }
        replayedMessages.clear();
    }
View Full Code Here

                    replayingEventStore.visitEvents(criteria, visitor);
                } else {
                    logger.trace("Starting visiting events without criteria");
                    replayingEventStore.visitEvents(visitor);
                }
                EventMessage lastMessage = visitor.getLastMessage();
                if (lastMessage != null) {
                    monitor.waitForLastMessageProcessed(lastMessage, getAfterReplayTimeout());
                }

                logger.trace("Notifying replay aware listeners 'afterReplay'");
View Full Code Here

    private UnitOfWorkFactory unitOfWorkFactory = new DefaultUnitOfWorkFactory();

    @Override
    public ScheduleToken schedule(DateTime triggerDateTime, Object event) {
        Assert.state(initialized, "Scheduler is not yet initialized");
        EventMessage eventMessage = GenericEventMessage.asEventMessage(event);
        String jobIdentifier = JOB_NAME_PREFIX + eventMessage.getIdentifier();
        QuartzScheduleToken tr = new QuartzScheduleToken(jobIdentifier, groupIdentifier);
        try {
            JobDetail jobDetail = buildJobDetail(eventMessage, new JobKey(jobIdentifier, groupIdentifier));
            scheduler.scheduleJob(jobDetail, buildTrigger(triggerDateTime, jobDetail.getKey()));
        } catch (SchedulerException e) {
View Full Code Here

                } catch (BrokenBarrierException e) {
                    fail("The barrier has been broken");
                }
                boolean mustContinue = true;
                while (mustContinue) {
                    EventMessage item = eventsToPublish.poll();
                    if (item == null) {
                        mustContinue = false;
                    } else {
                        sagaManager.handle(item);
                    }
View Full Code Here

    }

    @Override
    public void onMessage(Message message) {
        try {
            EventMessage eventMessage = messageConverter.readAMQPMessage(message.getBody(),
                                                                         message.getMessageProperties().getHeaders());
            if (eventMessage != null) {
                for (Cluster cluster : clusters) {
                    cluster.publish(eventMessage);
                }
View Full Code Here

            reporter.reportWrongEvent(publishedEvents, Arrays.asList(expectedEvents), actualException);
        }

        Iterator<EventMessage> iterator = publishedEvents.iterator();
        for (Object expectedEvent : expectedEvents) {
            EventMessage actualEvent = iterator.next();
            if (!verifyEventEquality(expectedEvent, actualEvent.getPayload())) {
                reporter.reportWrongEvent(publishedEvents, Arrays.asList(expectedEvents), actualException);
            }
        }
        return this;
    }
View Full Code Here

TOP

Related Classes of org.axonframework.domain.EventMessage

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.