Command handling exception if i am dispatching command to multiple services using AsynchrnousCommandBus/DisruptorCommandBus.

hi Allard/Steven,

im getting exception shown below, if im dispatching command which is handled in other service if i am using AsynchrnousCommansdBus/DisruptorCommandBus.

if i use default CommandBus(SimpleCommandBus) the command is dispatched from ServiceA and handled in ServiceB successfully without exception.

below is code snippet of my configuration in ServiceA.

@Bean(destroyMethod="shutdown")
@ConditionalOnMissingBean
public AsynchronousCommandBus commandBus(TransactionManager txManager, AxonConfiguration axonConfiguration) {
    AsynchronousCommandBus commandBus =
            AsynchronousCommandBus.builder()
                    .transactionManager(txManager)
                    .messageMonitor(axonConfiguration.messageMonitor(AsynchronousCommandBus.class, "commandBus"))
                    .build();
    commandBus.registerHandlerInterceptor(new CorrelationDataInterceptor<>(axonConfiguration.correlationDataProviders()));
    return commandBus;
}

@Bean
public CommandGateway commandGateway(AsynchronousCommandBus commandBus){
    /*Configurer configurer = DefaultConfigurer.defaultConfiguration();
    CommandBus commandBus = configurer.buildConfiguration().commandBus();*/
    ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
    RetryScheduler rs = IntervalRetryScheduler.builder().retryExecutor(scheduledExecutorService).maxRetryCount(5).retryInterval(1000).build();
    CommandGateway commandGateway = DefaultCommandGateway.builder().commandBus(commandBus).retryScheduler(rs).build();
    return commandGateway;
}

below is the exception stack-trace.

2020-06-29 11:59:54.397 INFO 7572 — [unt.handlers]-0] c.u.account.aggregate.AccountAggregate : Inside Create Account Process Event in CreateAccountaggregate
2020-06-29 11:59:54.403 INFO 7572 — [agaProcessor]-0] c.u.account.saga.AccountSaga : Inside AccountProcessEvent in Account MMT SAGA
2020-06-29 11:59:54.403 INFO 7572 — [agaProcessor]-0] c.u.account.saga.AccountSaga : Saga invoked for AccountProcessEvent
2020-06-29 11:59:54.403 INFO 7572 — [agaProcessor]-0] c.u.account.saga.AccountSaga : Account global id XXXXXXXXXXXXXXXXXXX
2020-06-29 11:59:54.403 INFO 7572 — [agaProcessor]-0] c.u.account.saga.AccountSaga : Fire Create Account Command In DB IN ServiceB
2020-06-29 11:59:54.410 INFO 7572 — [agaProcessor]-0] o.a.c.gateway.AbstractRetryScheduler : Processing of Command [CreateInDBCommand] resulted in an exception. Will retry 4 more time(s)… Exception was org.axonframework.commandhandling.NoHandlerForCommandException, No handler was subscribed to command [com.core.commands.CreateInDBCommand]
2020-06-29 11:59:55.411 INFO 7572 — [pool-1-thread-1] o.a.c.gateway.AbstractRetryScheduler : Processing of Command [CreateInDBCommand] resulted in an exception. Will retry 3 more time(s)… Exception was org.axonframework.commandhandling.NoHandlerForCommandException, No handler was subscribed to command [com.core.commands.CreateInDBCommand]
2020-06-29 11:59:56.414 INFO 7572 — [pool-1-thread-1] o.a.c.gateway.AbstractRetryScheduler : Processing of Command [CreateInDBCommand] resulted in an exception. Will retry 2 more time(s)… Exception was org.axonframework.commandhandling.NoHandlerForCommandException, No handler was subscribed to command [com.core.commands.CreateInDBCommand]
2020-06-29 11:59:57.416 INFO 7572 — [pool-1-thread-1] o.a.c.gateway.AbstractRetryScheduler : Processing of Command [CreateInDBCommand] resulted in an exception. Will retry 1 more time(s)… Exception was org.axonframework.commandhandling.NoHandlerForCommandException, No handler was subscribed to command [com.core.commands.CreateInDBCommand]
2020-06-29 11:59:58.417 INFO 7572 — [pool-1-thread-1] o.a.c.gateway.AbstractRetryScheduler : Processing of Command [CreateInDBCommand] resulted in an exception. Will retry 0 more time(s)… Exception was org.axonframework.commandhandling.NoHandlerForCommandException, No handler was subscribed to command [com.core.commands.CreateInDBCommand]
2020-06-29 11:59:59.440 INFO 7572 — [pool-1-thread-1] o.a.c.gateway.AbstractRetryScheduler : Processing of Command [CreateInDBCommand] resulted in an exception 6 times. Giving up permanently.

org.axonframework.commandhandling.NoHandlerForCommandException: No handler was subscribed to command [com.progressivecoder.ecommerce.commands.CreateInDbCommand]
at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:146) [axon-messaging-4.2.jar:4.2]
at org.axonframework.commandhandling.SimpleCommandBus.dispatch(SimpleCommandBus.java:111) [axon-messaging-4.2.jar:4.2]
at org.axonframework.commandhandling.gateway.RetryingCallback$RetryDispatch.run(RetryingCallback.java:120) [axon-messaging-4.2.jar:4.2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_201]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_201]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]

2020-06-29 11:59:59.441 WARN 7572 — [pool-1-thread-1] o.a.c.gateway.DefaultCommandGateway : Command ‘com.core.commands.CreateInDBCommand’ resulted in org.axonframework.commandhandling.NoHandlerForCommandException(No handler was subscribed to command [com.core.commands.CreateInDBCommand])

is that i am missing any configuration?

Any suggestion may be helpful.

Thanks
Siddu

exception.txt (4.07 KB)

suggestions from any axon users for solving this issue may be helpful.

Thanks
Siddu

hi allard/steven,

im expecting your help to solve this issue.

Thanks
Siddu

Hi Siddu,

Let me first state that posting a question here does not necessitate an answer from anyone in a given time frame.
Other community members could chip in, which is always very helpful of course.

Alongside that, it’s not just me and Allard on here, but the entire AxonIQ team.
From AxonIQ’s end we respond on question here on a best effort basis.
If you need a quicker response, I would recommend to open up a support contract with AxonIQ by contacting us at sales@axoniq.io.

Now, to your issue.
Neither the AsynchronousCommandBus nor the DisruptorCommandBus are intended for distributing command messages.
To that end, you should either use Axon Server, or configure the DistributedCommandBus.

The former is extremely trivial to achieve, as Axon Framework defaults to expecting an Axon Server instance to be present.
Configuring a DistributedCommandBus boils down to configuring the JGroups or Spring Cloud Axon extension.

Cheers,
Steven

PS. It is important to note that this mailing list will be discontinued as specified in this thread.
The thread also specifies where to look further for help when it comes to Axon as soon as this mailing list is closed.