@Override public void start() { config.start(); this.running = true; }
/** * Builds the configuration and starts it immediately. It is not recommended to change any configuration on this * Configurer once this method is called. * * @return The started configuration */ default Configuration start() { Configuration configuration = buildConfiguration(); configuration.start(); return configuration; } }
@Before public void setUp() { Configuration configuration = DefaultConfigurer.defaultConfiguration() .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine()) .configureAggregate(StubAggregate.class) .buildConfiguration(); configuration.start(); commandGateway = configuration.commandGateway(); }
@Test public void testDispatchCommand() { Configuration c = DefaultConfigurer.defaultConfiguration() .configureAggregate(TestAggregate.class) .registerCommandHandler(x -> new Handler()) .configureEmbeddedEventStore(x -> new InMemoryEventStorageEngine()) .buildConfiguration(); c.start(); CommandGateway gw = c.commandGateway(); gw.sendAndWait(new TestCommand()); }
@Test public void testStagedEventsLoadInCorrectOrder() { Configuration config = DefaultConfigurer.defaultConfiguration() .configureAggregate(TestAggregate.class) .registerCommandHandler(x -> new Handler()) .configureEmbeddedEventStore(x -> new InMemoryEventStorageEngine()) .registerComponent(List.class, c -> new CopyOnWriteArrayList()) .buildConfiguration(); config.start(); CommandGateway gw = config.commandGateway(); gw.sendAndWait(new Create("1")); gw.sendAndWait(new Test1()); gw.sendAndWait(new ShowItems("1", "from-eventstore")); config.shutdown(); assertEquals(asList("pre-rollback-first","pre-rollback-second", "post-rollback-first","post-rollback-second", "from-eventstore-first", "from-eventstore-second"), config.getComponent(List.class)); }
@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(); }
@Before public void setUp() { configuration = DefaultConfigurer.defaultConfiguration() .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine()) .configureAggregate(AggregateConfigurer.defaultConfiguration(MyAggregate.class) .configureAggregateFactory(c -> new AggregateFactory<MyAggregate>() { @Override public MyAggregate createAggregateRoot(String aggregateIdentifier, DomainEventMessage<?> firstEvent) { return new MyAggregate(aggregateIdentifier); } @Override public Class<MyAggregate> getAggregateType() { return MyAggregate.class; } })) .registerCommandHandler(c -> new MyCommandHandler(c.repository(MyAggregate.class), c.commandGateway())) .buildConfiguration(); configuration.start(); command = new MyCommand("outer", aggregateIdentifier, new MyCommand("middle", aggregateIdentifier, new MyCommand("inner", aggregateIdentifier))); }
/** * Builds the configuration and starts it immediately. It is not recommended to change any configuration on this * Configurer once this method is called. * * @return The started configuration */ default Configuration start() { Configuration configuration = buildConfiguration(); configuration.start(); return configuration; } }
/** * Builds the configuration and starts it immediately. It is not recommended to change any configuration on this * Configurer once this method is called. * * @return The started configuration */ default Configuration start() { Configuration configuration = buildConfiguration(); configuration.start(); return configuration; } }
@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); } }
.registerModule(SagaConfiguration.subscribingSagaManager(BuyTradeManagerSaga.class)) .buildConfiguration(); configuration.start(); return configuration;
public static void main(String args[]){ Configuration config = DefaultConfigurer.defaultConfiguration() .configureAggregate(BankAccount.class) .configureEmbeddedEventStore(c -> new InMemoryEventStorageEngine()) .buildConfiguration(); config.start(); AccountId id = new AccountId(); config.commandGateway().send(new CreateAccountCommand(id, "MyAccount",1000)); config.commandGateway().send(new WithdrawMoneyCommand(id, 500)); config.commandGateway().send(new WithdrawMoneyCommand(id, 500)); /*config.commandBus().dispatch(asCommandMessage(new CreateAccountCommand(id, "MyAccount", 1000))); config.commandBus().dispatch(asCommandMessage(new WithdrawMoneyCommand(id, 500)));*/ }