Package org.axonframework.eventhandling

Examples of org.axonframework.eventhandling.EventBus


        // we'll store Events on the FileSystem, in the "events" folder
        EventStore eventStore = new FileSystemEventStore(new SimpleEventFileResolver(new File("./events")));

        // a Simple Event Bus will do
        EventBus eventBus = new SimpleEventBus();

        // we need to configure the repository
        EventSourcingRepository<ToDoItem> repository = new EventSourcingRepository<ToDoItem>(ToDoItem.class, eventStore);
        repository.setEventBus(eventBus);

        // Register the Command Handlers with the command bus by subscribing to the name of the command
        commandBus.subscribe(CreateToDoItemCommand.class.getName(),
                new CreateToDoCommandHandler(repository));
        commandBus.subscribe(MarkCompletedCommand.class.getName(),
                new MarkCompletedCommandHandler(repository));

        // We register an event listener to see which events are created
        eventBus.subscribe(new ToDoEventListener());

        // and let's send some Commands on the CommandBus using the special runner configured with our CommandGateway.
        CommandGenerator.sendCommands(commandGateway);
    }
View Full Code Here


        verify(delegateCluster).unsubscribe(replayAware);
    }

    @Test
    public void testAnnotatedHandlersRecognized() {
        EventBus eventBus = new ClusteringEventBus(new DefaultClusterSelector(testSubject));
        MyReplayAwareListener annotatedBean = new MyReplayAwareListener();
        AnnotationEventListenerAdapter.subscribe(annotatedBean, eventBus);

        testSubject.startReplay();
View Full Code Here

    public void testSaveAggregate_RefusedDueToLackingLock() {
        lockManager = spy(new PessimisticLockManager());
        testSubject = new InMemoryLockingRepository(lockManager);
        testSubject.setEventBus(mockEventBus);
        testSubject = spy(testSubject);
        EventBus eventBus = mock(EventBus.class);

        DefaultUnitOfWork.startAndGet();
        StubAggregate aggregate = new StubAggregate();
        aggregate.doSomething();
        testSubject.add(aggregate);
View Full Code Here

    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.debug("Starting job to publish a scheduled event");
        Object event = context.getJobDetail().getJobDataMap().get(EVENT_KEY);
        EventMessage<?> eventMessage = createMessage(event);
        try {
            EventBus eventBus = (EventBus) context.getScheduler().getContext().get(EVENT_BUS_KEY);
            UnitOfWorkFactory unitOfWorkFactory =
                    (UnitOfWorkFactory) context.getScheduler().getContext().get(UNIT_OF_WORK_FACTORY_KEY);
            UnitOfWork uow = unitOfWorkFactory.createUnitOfWork();
            try {
                uow.publishEvent(eventMessage, eventBus);
View Full Code Here

        final DisruptorConfiguration configuration = new DisruptorConfiguration();
        final Serializer serializer = mock(Serializer.class);
        configuration.setSerializer(serializer);
        configuration.setSerializerThreadCount(3);
        configuration.setSerializedRepresentation(Document.class);
        EventBus mockEventBus = mock(EventBus.class);
        EventStore mockEventStore = mock(EventStore.class);
        testSubject = new DisruptorCommandBus(mockEventStore, mockEventBus, configuration);
        testSubject.subscribe(StubCommand.class.getName(), stubHandler);
        testSubject.subscribe(CreateCommand.class.getName(), stubHandler);
        testSubject.subscribe(ErrorCommand.class.getName(), stubHandler);
View Full Code Here

    @Test
    public void testSerializationOptimization_DisabledByDefault() {
        final DisruptorConfiguration configuration = new DisruptorConfiguration();
        configuration.setSerializerThreadCount(3);
        EventBus mockEventBus = mock(EventBus.class);
        EventStore mockEventStore = mock(EventStore.class);
        testSubject = new DisruptorCommandBus(mockEventStore, mockEventBus, configuration);
        testSubject.subscribe(StubCommand.class.getName(), stubHandler);
        testSubject.subscribe(CreateCommand.class.getName(), stubHandler);
        testSubject.subscribe(ErrorCommand.class.getName(), stubHandler);
View Full Code Here

    public void testSerializationOptimization_DisabledOnZeroSerializerThreads() {
        final DisruptorConfiguration configuration = new DisruptorConfiguration();
        final Serializer serializer = mock(Serializer.class);
        configuration.setSerializer(serializer);
        configuration.setSerializerThreadCount(0);
        EventBus mockEventBus = mock(EventBus.class);
        EventStore mockEventStore = mock(EventStore.class);
        testSubject = new DisruptorCommandBus(mockEventStore, mockEventBus, configuration);
        testSubject.subscribe(StubCommand.class.getName(), stubHandler);
        testSubject.subscribe(CreateCommand.class.getName(), stubHandler);
        testSubject.subscribe(ErrorCommand.class.getName(), stubHandler);
View Full Code Here

            return mock(EventBus.class);
        }

        @Bean
        public EventBus alternativeEventBus() {
            final EventBus mock = mock(EventBus.class);
            doThrow(new AssertionError("Should not interact with this event bus"))
                    .when(mock)
                    .subscribe(any(EventListener.class));
            return mock;
        }
View Full Code Here

                                                                    .getValue();
        assertEquals("constructor value is wrong", AutowiringClusterSelector.class.getName(),
                     selectorDef.getBeanClassName());


        EventBus eventBus = beanFactory.getBean("eventBus", EventBus.class);
        assertNotNull(eventBus);
    }
View Full Code Here

    @SuppressWarnings({"unchecked"})
    public AnnotatedSagaTestFixture(Class<? extends AbstractAnnotatedSaga> sagaType) {
        eventScheduler = new StubEventScheduler();
        GenericSagaFactory genericSagaFactory = new GenericSagaFactory();
        genericSagaFactory.setResourceInjector(new AutowiredResourceInjector(registeredResources));
        EventBus eventBus = new SimpleEventBus();
        InMemorySagaRepository sagaRepository = new InMemorySagaRepository();
        sagaManager = new AnnotatedSagaManager(sagaRepository, genericSagaFactory, sagaType);
        sagaManager.setSuppressExceptions(false);

        registeredResources.add(eventBus);
View Full Code Here

TOP

Related Classes of org.axonframework.eventhandling.EventBus

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.