J'ai un agrégat de coureur de rapport qui gère la commande d'exécution de rapport. L'agrégat a un identificateur de cible et les deux commandes ont le même identificateur de cible.Axon Error: java.lang.IllegalArgumentException: L'unité de travail a déjà un agrégat avec le même identifiant
Obtenir l'erreur suivante
java.lang.IllegalArgumentException: L'unité de travail a déjà un agrégat avec le même identifiant à 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.commandhand ling.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]
Quelque chose comme
public class ExecuteReportsAggregate
{
@AggregateIdentifier
private String reportId;
// Command Handler and Even Source Handlers
}
Exécuter Command Signaler un
@Value
public class ExecuteReportCommand
{
@TargetAggregateIdentifier
String reportId;
}
Rapport Exécuté Commande
@Value
public class ReportExecutedCommand
{
// @TargetAggregateIdentifier
private String reportId;
}
botte de printemps ressemble à ce
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")));
}
Je pense que vous devez fournir le code pour le signifiantes @ CommandHandlers' et '@ EventSourcingHandlers' pour nous de dire quelque chose de sensé à ce sujet. – Allard