-
Notifications
You must be signed in to change notification settings - Fork 826
Description
Look really weird, must be something I configuration incorrect, any advice will be very appriciated..
Aggregate root:
@AggregateRoot public class Portfolio { @AggregateIdentifier private String accountId; private Map<Currency, Cash> cash = new ConcurrentHashMap<>(); }
Create logic:
`
CreateAccountCommand command = new CreateAccountCommand(accountId, id);
try {
commandGateway.send(command, new CommandCallback<CreateAccountCommand, Object>() {
@OverRide
public void onSuccess(CommandMessage<? extends CreateAccountCommand> commandMessage, Object result) {
commandGateway.send(new DepositCashCommand(userId, Cash.asUSD(1000d)));
}
@Override
public void onFailure(CommandMessage<? extends CreateAccountCommand> commandMessage, Throwable cause) {
cause.printStackTrace();
System.exit(1);
}
});
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
`
Event handler side:
`
@eventhandler
public void handleCashDepositedEvent(CashDepositedEvent event)
@eventhandler
public void handleAccountCreatedEvent(AccountCreatedEvent event)
`
Bus:
`
@bean
@Profile("disruptor")
public CommandBus commandBus(@Autowired EventStore es){
DisruptorConfiguration configuration = new DisruptorConfiguration();
configuration.getDispatchInterceptors().add(new BeanValidationInterceptor<>());
configuration
.setInvokerThreadCount(Runtime.getRuntime().availableProcessors()/2)
.setPublisherThreadCount(1); //1 always work ? 1 not work
DisruptorCommandBus cb = new DisruptorCommandBus(es, configuration);
return cb;
}
`
If I test public 10 CreateAccountCommand always be 4~5 account reach EventHandler side..
If I setPublisherThreadCount(1) or switch to simple bus always work correct.