@Qualifier("eventStore") @Bean(name = "eventBus") @ConditionalOnMissingBean(EventBus.class) @ConditionalOnBean(EventStorageEngine.class) public EmbeddedEventStore eventStore(EventStorageEngine storageEngine, AxonConfiguration configuration) { return EmbeddedEventStore.builder() .storageEngine(storageEngine) .messageMonitor(configuration.messageMonitor(EventStore.class, "eventStore")) .build(); }
@Override public Configurer configureEmbeddedEventStore(Function<Configuration, EventStorageEngine> storageEngineBuilder) { return configureEventStore(c -> { MessageMonitor<Message<?>> monitor = messageMonitorFactoryComponent.get().apply(EmbeddedEventStore.class, "eventStore"); EmbeddedEventStore eventStore = EmbeddedEventStore.builder() .storageEngine(storageEngineBuilder.apply(c)) .messageMonitor(monitor) .build(); c.onShutdown(eventStore::shutDown); return eventStore; }); }
return null; }).when(mockTransactionManager).executeInTransaction(any(Runnable.class)); eventBus = EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build(); sleepInstructions = new ArrayList<>(); TrackingEventProcessor.Builder eventProcessorBuilder =
@Override public Configurer configureEmbeddedEventStore(Function<Configuration, EventStorageEngine> storageEngineBuilder) { return configureEventStore(c -> { MessageMonitor<Message<?>> monitor = messageMonitorFactoryComponent.get().apply(EmbeddedEventStore.class, "eventStore"); EmbeddedEventStore eventStore = EmbeddedEventStore.builder() .storageEngine(storageEngineBuilder.apply(c)) .messageMonitor(monitor) .build(); c.onShutdown(eventStore::shutDown); return eventStore; }); }
@Qualifier("eventStore") @Bean(name = "eventBus") @ConditionalOnMissingBean(EventBus.class) @ConditionalOnBean(EventStorageEngine.class) public EmbeddedEventStore eventStore(EventStorageEngine storageEngine, AxonConfiguration configuration) { return EmbeddedEventStore.builder() .storageEngine(storageEngine) .messageMonitor(configuration.messageMonitor(EventStore.class, "eventStore")) .build(); }
Thread[] writerThreads = storeEvents(threadCount, eventsPerThread, inverseRollbackRate); EmbeddedEventStore embeddedEventStore = EmbeddedEventStore.builder() .storageEngine(testSubject) .cachedEvents(20) .fetchDelay(100)
protected AbstractEventStoreBenchmark(EventStorageEngine storageEngine, int threadCount, int batchSize, int batchCount) { this.eventStore = EmbeddedEventStore.builder() .storageEngine(this.storageEngine = storageEngine) .build(); this.threadCount = threadCount;
@Before public void setUp() { aggregateIdentifier = UUID.randomUUID().toString(); commandBus = SimpleCommandBus.builder().build(); eventStore = spy(EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build()); eventStore.publish(new GenericDomainEventMessage<>("test", aggregateIdentifier, 0, new AggregateCreatedEvent(aggregateIdentifier), null)); reset(eventStore); reportErrorCallback = (commandMessage, commandResultMessage) -> { if (commandResultMessage.isExceptional()) { Throwable cause = commandResultMessage.exceptionResult(); throw new RuntimeException("Failure", cause); } }; expectErrorCallback = (commandMessage, commandResultMessage) -> { if (commandResultMessage.isExceptional()) { Throwable cause = commandResultMessage.exceptionResult(); assertEquals("Mock exception", cause.getMessage()); } else { fail("Expected this command to fail"); } }; }
@Test(timeout = 10000) public void testInsertConcurrentlyAndReadUsingBlockingStreams() throws Exception { int threadCount = 10, eventsPerThread = 100, inverseRollbackRate = 2, rollbacksPerThread = (eventsPerThread + inverseRollbackRate - 1) / inverseRollbackRate; int expectedEventCount = threadCount * eventsPerThread - rollbacksPerThread * threadCount; Thread[] writerThreads = storeEvents(threadCount, eventsPerThread, inverseRollbackRate); EmbeddedEventStore embeddedEventStore = EmbeddedEventStore.builder().storageEngine(testSubject).build(); TrackingEventStream readEvents = embeddedEventStore.openStream(null); int counter = 0; while (counter < expectedEventCount) { if (readEvents.hasNextAvailable()) { counter++; } } for (Thread thread : writerThreads) { thread.join(); } assertEquals("The actually read list of events is shorted than the expected value", expectedEventCount, counter); }
@Before public void setUp() { tokenStore = spy(new InMemoryTokenStore()); mockHandler = mock(EventMessageHandler.class); when(mockHandler.canHandle(any())).thenReturn(true); eventHandlerInvoker = SimpleEventHandlerInvoker.builder() .eventHandlers(singletonList(mockHandler)) .sequencingPolicy(event -> { if (event instanceof DomainEventMessage) { return ((DomainEventMessage) event) .getSequenceNumber(); } return event.getIdentifier(); }) .build(); eventBus = EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build(); // A processor config, with a policy which guarantees segmenting by using the sequence number. configureProcessor(TrackingEventProcessorConfiguration.forParallelProcessing(2)); }
@Before public void setUp() { EventStore eventStore = spy(EmbeddedEventStore.builder() .storageEngine(new InMemoryEventStorageEngine()) .build()); Configurer configurer = DefaultConfigurer.defaultConfiguration(); configurer.eventProcessing() .usingSubscribingEventProcessors() .registerSaga(MySaga.class); configuration = configurer.configureEventStore(c -> eventStore) .configureAggregate(MyAggregate.class) .registerComponent(DeadlineManager.class, this::buildDeadlineManager) .start(); published = new CopyOnWriteArrayList<>(); configuration.eventBus().subscribe(msgs -> msgs.forEach(msg -> published.add(msg.getPayload()))); }
@SuppressWarnings("unchecked") @Before public void setUp() { eventStore = spy(EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build()); Repository<MyAggregate> myAggregateRepository = EventSourcingRepository.builder(MyAggregate.class) .eventStore(eventStore) .build(); CommandBus commandBus = SimpleCommandBus.builder().build(); commandGateway = DefaultCommandGateway.builder().commandBus(commandBus).build(); AggregateAnnotationCommandHandler<MyAggregate> myAggregateCommandHandler = AggregateAnnotationCommandHandler.<MyAggregate>builder() .aggregateType(MyAggregate.class) .repository(myAggregateRepository) .build(); myAggregateCommandHandler.subscribe(commandBus); }
@Before public void setUp() { this.commandBus = SimpleCommandBus.builder().build(); eventStore = spy(EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build()); EventSourcingRepository<StubAggregate> repository = EventSourcingRepository.builder(StubAggregate.class) .eventStore(eventStore) .build(); StubAggregateCommandHandler target = new StubAggregateCommandHandler(); target.setRepository(repository); target.setEventBus(eventStore); new AnnotationCommandHandlerAdapter<>(target).subscribe(commandBus); }
@Before public void setUp() { mockHandler = mock(EventMessageHandler.class); eventHandlerInvoker = SimpleEventHandlerInvoker.builder().eventHandlers(mockHandler).build(); eventBus = EmbeddedEventStore.builder().storageEngine(new InMemoryEventStorageEngine()).build(); testSubject = SubscribingEventProcessor.builder() .name("test") .eventHandlerInvoker(eventHandlerInvoker) .messageSource(eventBus) .build(); }