Getting exception when doing QueryHandling, org.axonframework.queryhandling.NoHandlerForQueryException: No handler for query

hi axon team,

i am trying to fetch Account details from Service-B where i am handling query by @QueryHandler. The query is fired from Service-A.

  1. it was working fine when i was not using EurekaDiscoveryClient .
  2. when i added eureka discovery client i added springCloudHttpBackupCommandRouter
    and i added few configurations which can be found here https://groups.google.com/g/axonframework/c/RPfCE5Sqm3I , now i can able to handle commands and events between multiple services.
  3. but i cannot handle Query request between multiple service.
  4. im scanning the packages where the QueryHandlers are present as specified by Allard, that didnt resolve the issue

please any one help me out solving this issue. below is my code snippet.

from Service A im firing the Query.
CompletableFuture account = queryGateway.query(
new AccountDetailsQuery(accountId), ResponseTypes.instanceOf( Account .class));

where AccountDetailsQuery will be in core-api and ll be added as jar file in both service-A and in Service B.

im handling that Query in Service-B using @QueryHandler
@QueryHandler
public Account getAccountDetails(AccountDetailsQuery query) throws Exception {
log.info(LoggingConstants.QUERY_INVOKE_LOG,query.getClass().getSimpleName());
return new Account(query.getAccountId(),“afffef”)
}

im scaning this package too.

@Bean
public QueryGateway getQueryGateway(SimpleQueryBus simpleQueryBus){
/Configurer configurer = DefaultConfigurer.defaultConfiguration();
QueryBus queryBus = configurer.buildConfiguration().queryBus();
/
return DefaultQueryGateway.builder().queryBus(simpleQueryBus).build();
}

im getting excepton as
2020-08-13 18:45:14 [EventProcessor[AccountManagementSagaProcessor]-0] WARN o.a.c.gateway.DefaultCommandGateway - Command ‘com.xxx.xxx.core.api.AccountCommand’ resulted in java.util.concurrent.ExecutionException(org.axonframework.queryhandling.NoHandlerForQueryException: No handler for query: com.xxx.xxx.core.api.AccountDetailsQuery)

it would be helpful if anyone resolves this issue.

Thanks
Siddu

hi,

Sorry, i forgot to mention the axon version. I am using Axon 4.3.

Hi Siddu,

AxonFramework doesn’t have a DistributedQueryBus implementation for Spring Cloud Discovery. There is only a SimpleQueryBus and an AxonServerQueryBus implementation available.
That means distributed query messages is currently only supported (out of the box) when using AxonServer.