After switching to the distributed command bus, the local aggregate commandhandlers aren’t registered.
I keep getting the “No node known to accept” error.
I’ve come across https://groups.google.com/forum/#!topic/axonframework/BXUFcSZEuoI but according to this, the issue should’ve been fixed since 3.0.4
my local service’s config looks like this:
@Configuration
@AutoConfigureAfter(AxonAutoConfiguration.class)
public class OrchestratorConfig {
@Autowired
private Registration registration;
private RestTemplate restTemplate = new RestTemplate();
@Bean
public CommandBusConnector springHttpCommandBusConnector(@Qualifier("localSegment") CommandBus localSegment,
Serializer serializer) {
return new SpringHttpCommandBusConnector(localSegment, restTemplate, serializer);
}
@Bean
public CommandRouter springCloudCommandRouter(DiscoveryClient discoveryClient) {
return new SpringCloudCommandRouter(discoveryClient, registration, new AnnotationRoutingStrategy());
}
@Bean
@Primary
public DistributedCommandBus springCloudDistributedCommandBus(CommandRouter commandRouter,
CommandBusConnector springHttpCommandBusConnector) {
return new DistributedCommandBus(commandRouter, springHttpCommandBusConnector);
}
}
my Aggregate
@Aggregate
@Slf4j
@Data
@NoArgsConstructor
public class CreateCurrencyAggregate {
@AggregateIdentifier
private String createCurrencyId;
@CommandHandler
public CreateCurrencyAggregate(CreateCurrencyCommand command) {
log.info("starting create currency");
Assert.notNull(command.getId(), "CreateCurrencyCommand must have an id");
Assert.hasLength(command.getId(), "CreateCurrencyCommand id cannot be an empty String");
this.createCurrencyId = command.getId();
apply(CreateCurrencyEvent.builder()
.id(command.getId())
.payload(command.getPayload())
.build());
}
@CommandHandler
public void handle(DalCreatedCommand command) {
log.info("returning from dal service");
Assert.notNull(command.getId(), "DalCreatedCommand must have an id");
apply(DalCurrencyCreatedEvent.builder()
.transactionId(command.getId())
.build());
}
@CommandHandler
public void handle(As400CreatedCommand command) {
log.info("returning from as400 service");
Assert.notNull(command.getId(), "As400CreatedCommand must have an id");
apply(As400CurrencyCreatedEvent.builder()
.transactionId(command.getId())
.build());
}
}
dependencies