我有一个报告运行器聚合,它正在处理报告运行命令。聚合具有目标标识符,并且两个命令具有相同的目标标识符。
收到以下错误
java.lang.IllegalArgumentException:工作单元在 org.axonframework.common.Assert.isTrue(Assert.java:54) ~[axon-core-3.0.6.jar:3.0.6 处已经有一个具有相同标识符的聚合] 在 org.axonframework.commandhandling.model.AbstractRepository.newInstance(AbstractRepository.java:84) ~[axon-core-3.0.6.jar:3.0.6] 在 org.axonframework.commandhandling.AggregateAnnotationCommandHandler$AggregateConstructorCommandHandler.handle(AggregateAnnotationCommandHandler .java:181) ~[axon-core-3.0.6.jar:3.0.6] 在 org.axonframework.commandhandling.AggregateAnnotationCommandHandler$AggregateConstructorCommandHandler.handle(AggregateAnnotationCommandHandler.java:170) ~[axon-core-3.0.6。 jar:3.0.6] 在 org.axonframework.commandhandling.AggregateAnnotationCommandHandler.handle(AggregateAnnotationCommandHandler.java:148) ~[axon-core-3.0.6.jar:3.0.6] 在 org.axonframework.commandhandling.AggregateAnnotationCommandHandler.handle(AggregateAnnotationCommandHandler.java:40) ~[axon-core-3.0.6.jar:3.0.6]
就像是
public class ExecuteReportsAggregate
{
@AggregateIdentifier
private String reportId;
// Command Handler and Even Source Handlers
}
执行报告命令
@Value
public class ExecuteReportCommand
{
@TargetAggregateIdentifier
String reportId;
}
报告执行的命令
@Value
public class ReportExecutedCommand
{
// @TargetAggregateIdentifier
private String reportId;
}
弹簧靴看起来像这样
public static void main(String[] args)
{
ConfigurableApplicationContext config = SpringApplication.run(SsmpPreopenCommand.class, args);
CommandBus commandBus = config.getBean(CommandBus.class);
commandBus.dispatch(GenericCommandMessage.asCommandMessage(new ExecuteReportCommand("12345",
"asdfasdf Errors", "/home/teo", new ServiceCredentials())));
// commandBus.dispatch(GenericCommandMessage.asCommandMessage(new
// ReportExecutedCommand("12345")));
}