Not able to configure localSegment as Distruptor command bus with Distributed command bus

Hi,

In our axon implementation we are using Distributed command bus with default local segment configuration.

We are now trying to use Distruptor command bus with

<axon:disruptor-command-bus id=“disruptorCommandBus” event-store=“eventStore” event-bus=“eventBus”>
axon:publisher-interceptors/
axon:repositories
<axon:repository id=“conversationAggregate” aggregate-type=“com.aggregate.ConversationAggregate”/>
</axon:repositories>
</axon:disruptor-command-bus>



We are getting below exception :

org.springframework.context.ApplicationContextException: Failed to start bean ‘__axon-annotation-command-handler-bean-post-processor’; nested exception is java.lang.IllegalStateException: If no specific CommandBus is provided, the application context must contain exactly one bean of type CommandBus. The current application context has: 2
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:176)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:773)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:485)
at com.sprint.vsb.em.EMClient.main(EMClient.java:111)
Caused by: java.lang.IllegalStateException: If no specific CommandBus is provided, the application context must contain exactly one bean of type CommandBus. The current application context has: 2
at org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor.ensureCommandBusInitialized(AnnotationCommandHandlerBeanPostProcessor.java:67)
at org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor.subscribe(AnnotationCommandHandlerBeanPostProcessor.java:90)
at org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor.subscribe(AnnotationCommandHandlerBeanPostProcessor.java:37)
at org.axonframework.common.annotation.AbstractAnnotationHandlerBeanPostProcessor.start(AbstractAnnotationHandlerBeanPostProcessor.java:165)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173)
… 7 more

Thanks,

If you have more than one command bus in your spring context, you must specify which one you wish to use:

You can add this information in your axon:annotation-config element:
<axon:annotation-config command-bus=“commandBus”/>

Cheers,

Allard

Thanks Allard it worked for me.