使用轴突框架我有错误:
汇总标识符在应用事件后必须是非零子。确保在处理创建事件时最新初始化了聚合标识符。 我使用此storageengine:
@Bean
public JdbcEventStorageEngine jdbcEventStorageEngine() throws Exception{
return new JdbcEventStorageEngine(dataSource::getConnection, NoTransactionManager.INSTANCE);
}
第二次收到ExcregateID的消息时,代码会失败:
@CommandHandler
public void handle(CreateProductCommand command) throws Exception {
Aggregate<Product> productAggregate = null;
try {
productAggregate = repository.load(command.getId());
} catch (AggregateNotFoundException exception) {
logger.info("Aggregate with " + command.getId() + " is not found. Creating new one...");
productAggregate = repository.newInstance(() -> new Product(command.getId()));
}
productAggregate.execute(product -> product.createProduct(command.getId()));
}
但是,如果我使用它,则可以正常工作:
@Bean
public EventStorageEngine eventStorageEngine() {
return new InMemoryEventStorageEngine();
}
我应该如何为Postgres/MySQL数据库配置EventStorageEngine?
删除Spring Devtools的效果很好。