@Override public void configureModule(Configurer configurer) { configurer.registerComponent(AxonServerConfiguration.class, c -> new AxonServerConfiguration()); configurer.registerComponent(AxonServerConnectionManager.class, c -> buildAxonServerConnectionManager(c)); configurer.configureEventStore(this::buildEventStore); configurer.configureCommandBus(this::buildCommandBus); configurer.configureQueryBus(this::buildQueryBus); configurer.registerModule(new EventProcessorInfoConfiguration()); configurer.registerComponent(TokenStore.class, c -> { logger.warn("BEWARE! Falling back to an in-memory token store. It is highly recommended to configure a " + "persistent implementation, based on the activity of the handler."); return new InMemoryTokenStore(); }); }
.ifPresent(commandBus -> configurer.configureCommandBus(c -> getBean(commandBus, c))); findComponent(QueryBus.class) .ifPresent(queryBus -> configurer.configureQueryBus(c -> getBean(queryBus, c)));
@Test public void testQueryHandlerAndEventHandlerCleanlyShutdown() { UserSummaryProjection userSummaryProjection = new UserSummaryProjection(); Configurer configurer = DefaultConfigurer.defaultConfiguration(); configurer.configureCommandBus(c -> SimpleCommandBus.builder().build()) .configureQueryBus(c -> SimpleQueryBus.builder().build()) .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine()) .registerQueryHandler(c -> userSummaryProjection); configurer.eventProcessing() .registerEventHandler(c -> userSummaryProjection); Configuration configuration = configurer.buildConfiguration(); configuration.start(); configuration.shutdown(); }
@Override public void configureModule(Configurer configurer) { configurer.registerComponent(AxonServerConfiguration.class, c -> new AxonServerConfiguration()); configurer.registerComponent(AxonServerConnectionManager.class, c -> buildAxonServerConnectionManager(c)); configurer.configureEventStore(this::buildEventStore); configurer.configureCommandBus(this::buildCommandBus); configurer.configureQueryBus(this::buildQueryBus); configurer.registerModule(new EventProcessorInfoConfiguration()); configurer.registerComponent(TokenStore.class, c -> { logger.warn("BEWARE! Falling back to an in-memory token store. It is highly recommended to configure a " + "persistent implementation, based on the activity of the handler."); return new InMemoryTokenStore(); }); }
@SneakyThrows public static void disabledMain(String[] args) { final Configuration configuration = DefaultConfigurer.defaultConfiguration() .configureAggregate(Entrance.class) .configureAggregate(Guest.class) .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine()) .configureCommandBus(c -> new AsynchronousCommandBus()) .buildConfiguration(); configuration.start(); final CommandBus commandBus = configuration.commandBus(); commandBus.dispatch(asCommandMessage(new RegisterEntranceCommand("main"))); commandBus.dispatch(asCommandMessage(new UnlockEntranceCommand("main"))); commandBus.dispatch(asCommandMessage(new UnregisterEntranceCommand("main")) ); TimeUnit.SECONDS.sleep(1L); } }
.configureCommandBus(conf -> commandBus) .configureEventStore(conf -> eventStore) .configureAggregate(User.class)