Examples of ToDoItemCompletedEvent


Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

        EventBus eventBus = new ClusteringEventBus(clusterSelector);
        eventBus.subscribe(new AnnotationEventListenerAdapter(new ThreadPrintingEventListener()));
        eventBus.subscribe(new AnnotationEventListenerAdapter(new AnotherThreadPrintingEventListener()));

        // publish an event
        eventBus.publish(asEventMessage(new ToDoItemCompletedEvent("todo1")));

        // we need to shutdown the executor we have created to prevent the JVM from hanging on shutdown
        // this also wait until all scheduled tasks for that thread have been executed
        executor.shutdown();
    }
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

        // We create 2 items
        eventBus.publish(asEventMessage(new ToDoItemCreatedEvent("todo1", "Got something to do")));
        eventBus.publish(asEventMessage(new ToDoItemCreatedEvent("todo2", "Got something else to do")));
        // We mark the first completed, before the deadline expires. The Saga has a hard-coded deadline of 2 seconds
        eventBus.publish(asEventMessage(new ToDoItemCompletedEvent("todo1")));
        // we wait 3 seconds. Enough time for the deadline to expire
        Thread.sleep(3000);
        // Just a System out to remind us that we should see something
        System.out.println("Should have seen an item marked overdue, now");
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

    public ToDoItem(String id, String description) {
        apply(new ToDoItemCreatedEvent(id, description));
    }

    public void markCompleted() {
        apply(new ToDoItemCompletedEvent(id));
    }
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

                                                          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"))
        ));
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

        // We create 2 items
        eventBus.publish(asEventMessage(new ToDoItemCreatedEvent("todo1", "Got something to do")));
        eventBus.publish(asEventMessage(new ToDoItemCreatedEvent("todo2", "Got something else to do")));
        // We mark the first completed, before the deadline expires. The Saga has a hard-coded deadline of 2 seconds
        eventBus.publish(asEventMessage(new ToDoItemCompletedEvent("todo1")));
        // we wait 3 seconds. Enough time for the deadline to expire
        Thread.sleep(3000);
        // Just a System out to remind us that we should see something
        System.out.println("Should have seen an item marked overdue, now");
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

        final DomainEventMessage[] domainEventMessages = {
                new GenericDomainEventMessage<ToDoItemCreatedEvent>(
                        "todo1", 0, new ToDoItemCreatedEvent("todo1", "Need to do something")),
                new GenericDomainEventMessage<ToDoItemCreatedEvent>(
                        "todo2", 0, new ToDoItemCreatedEvent("todo2", "Another thing to do")),
                new GenericDomainEventMessage<ToDoItemCompletedEvent>("todo2", 0, new ToDoItemCompletedEvent("todo2"))
        };
        eventStore.appendEvents("mock", new SimpleDomainEventStream(domainEventMessages));

        // we create an executor service with a single thread and start the replay as an asynchronous process
        ExecutorService executor = Executors.newSingleThreadExecutor();
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

        final DomainEventMessage[] domainEventMessages = {
                new GenericDomainEventMessage<ToDoItemCreatedEvent>(
                        "todo1", 0, new ToDoItemCreatedEvent("todo1", "Need to do something")),
                new GenericDomainEventMessage<ToDoItemCreatedEvent>(
                        "todo2", 0, new ToDoItemCreatedEvent("todo2", "Another thing to do")),
                new GenericDomainEventMessage<ToDoItemCompletedEvent>("todo2", 0, new ToDoItemCompletedEvent("todo2"))
        };
        eventStore.appendEvents("mock", new SimpleDomainEventStream(domainEventMessages));

        // we get the executor service from the application context and start the replay as an asynchronous process
        Future<Void> future = replayingCluster.startReplay(executor);
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

        // We start up a Spring context. In web applications, this is normally done through a context listener
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("cluster-config.xml");

        // we get the event bus from the application context
        EventBus eventBus = applicationContext.getBean(EventBus.class);
        eventBus.publish(asEventMessage(new ToDoItemCompletedEvent("todo1")));

        // we close the application context to make sure everything shuts down properly
        applicationContext.stop();
        applicationContext.close();
    }
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

        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"))
        ));
View Full Code Here

Examples of org.axonframework.quickstart.api.ToDoItemCompletedEvent

            ToDoItemCreatedEvent event = (ToDoItemCreatedEvent) eventMessage.getPayload();
            System.out.println(String.format("We've got something to do: %s (%s)",
                                             event.getDescription(),
                                             event.getTodoId()));
        } else if (eventMessage.getPayloadType().equals(ToDoItemCompletedEvent.class)) {
            ToDoItemCompletedEvent event = (ToDoItemCompletedEvent) eventMessage.getPayload();
            System.out.println(String.format("We've completed the task with id %s", event.getTodoId()));
        }
    }
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.