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

108 views
Skip to first unread message

Sankalp Sontakke

unread,
Jul 7, 2015, 8:21:39 AM7/7/15
to axonfr...@googlegroups.com
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 

<bean id="commandBus" class="org.axonframework.commandhandling.distributed.DistributedCommandBus">
        <constructor-arg ref="jGroupsConnector"/>
<constructor-arg ref="annotationRoutingStrategy"/>
            <property name="commandDispatchInterceptors">
          <list>
            <ref bean="commandEnricherInterceptor"/>
          </list>
        </property>
    </bean>
<bean id="jGroupsConnector" 
class="org.axonframework.commandhandling.distributed.jgroups.JGroupsConnectorFactoryBean">
<property name="configuration" value="tcp_gossip.xml" />
<property name="clusterName" value="myCluster" />
<property name="loadFactor" value="#{systemProperties['jgroups.loadFactor']}" />
<property name="localSegment" ref="disruptorCommandBus" />  
</bean>
<bean class="org.axonframework.commandhandling.annotation.AnnotationCommandHandlerBeanPostProcessor">
        <property name="commandBus" ref="commandBus"/>
    </bean>
<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>
 
<bean id="commandGateway"
class="org.axonframework.commandhandling.gateway.CommandGatewayFactoryBean">
<property name="commandBus" ref="commandBus" />
</bean>
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,

Allard Buijze

unread,
Jul 7, 2015, 10:28:11 AM7/7/15
to axonfr...@googlegroups.com
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


--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sankalp Sontakke

unread,
Jul 8, 2015, 7:29:16 AM7/8/15
to axonfr...@googlegroups.com
Thanks Allard it worked for me.
Reply all
Reply to author
Forward
0 new messages