public void setAccountId(String accountId) { this.accountId = new AccountId(accountId); }
@Id public String getAccountId() { return accountId.toString(); }
@RequestMapping(method = RequestMethod.POST) public void create() { LOGGER.info("start"); AccountId id = new AccountId(); LOGGER.debug("Account id: {}", id.toString()); commandGateway.send(new CreateAccountCommand(id, "MyAccount",1000)); commandGateway.send(new WithdrawMoneyCommand(id, 500)); commandGateway.send(new WithdrawMoneyCommand(id, 300)); /*config.commandBus().dispatch(asCommandMessage(new CreateAccountCommand(id, "MyAccount", 1000))); config.commandBus().dispatch(asCommandMessage(new WithdrawMoneyCommand(id, 500)));*/ } }
@RequestMapping(method = RequestMethod.POST) public void create() { LOGGER.info("start"); AccountId id = new AccountId(); LOGGER.debug("Account id: {}", id.toString()); commandGateway.send(new CreateAccountCommand(id, "MyAccount",1000)); commandGateway.send(new WithdrawMoneyCommand(id, 500)); commandGateway.send(new WithdrawMoneyCommand(id, 300)); commandGateway.send(new CreateAccountCommand(id, "MyAccount", 1000)); commandGateway.send(new WithdrawMoneyCommand(id, 500)); } }
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)));*/ }