public static void main(String[] args) throws InterruptedException {
    CountingEventBus eventBus = new CountingEventBus();
    StubHandler stubHandler = new StubHandler();
    InMemoryEventStore inMemoryEventStore = new InMemoryEventStore();
    DisruptorCommandBus<StubAggregate> commandBus =
        new DisruptorCommandBus<StubAggregate>(
            new GenericAggregateFactory<StubAggregate>(StubAggregate.class),
            inMemoryEventStore,
            eventBus,
            new CommandTargetResolver() {
              @Override
              public VersionedAggregateIdentifier resolveTarget(CommandMessage<?> command) {
                return new VersionedAggregateIdentifier(
                    command.getMetaData().get(TARGET_AGGREGATE_PROPERTY), null);
              }
            });
    commandBus.subscribe(StubCommand.class, stubHandler);
    stubHandler.setRepository(commandBus);
    final String aggregateIdentifier = "MyID";
    inMemoryEventStore.appendEvents(
        StubAggregate.class.getSimpleName(),
        new SimpleDomainEventStream(
            new GenericDomainEventMessage<StubDomainEvent>(
                aggregateIdentifier, 0, new StubDomainEvent())));

    long start = System.currentTimeMillis();
    for (int i = 0; i < COMMAND_COUNT; i++) {
      CommandMessage<StubCommand> command =
          new GenericCommandMessage<StubCommand>(
              new StubCommand(aggregateIdentifier),
              Collections.singletonMap(TARGET_AGGREGATE_PROPERTY, (Object) aggregateIdentifier));
      commandBus.dispatch(command);
    }
    System.out.println("Finished dispatching!");

    inMemoryEventStore.countDownLatch.await(5, TimeUnit.SECONDS);
    long end = System.currentTimeMillis();
    try {
      assertEquals(
          "Seems that some events are not published", 0, eventBus.publisherCountDown.getCount());
      assertEquals(
          "Seems that some events are not stored", 0, inMemoryEventStore.countDownLatch.getCount());
      System.out.println(
          "Did " + ((COMMAND_COUNT * 1000L) / (end - start)) + " commands per second");
    } finally {
      commandBus.stop();
    }
  }