Why does the Simple CommandBus take a transactionManager while the Distributed doesn't?

Comparing the configuration of the SimpleCommandBus and DistributedCommandBus from the quick start guide I noticed that a transaction manager is supplied to the former, nut not the later.

`
<axon:command-bus id=“commandBus” transaction-manager=“transactionManager”/>

VS

`

Is this intentional? Is it not possible to assign a transactionManager to a DistributedCommandBus?
How do I run my handler is a transaction then?

I tried:

`
@CommandHandler
@Transactional
public void handle(final CreateUserCommand command) {
Person person = new Person();
person.setName(command.getName());
person.setCountry( command.getCountry());
this.personDAO.addPerson(person);

Session session = this.sessionFactory.getCurrentSession();
session.persist§;
}
`

But I keep getting this exception:


org.hibernate.HibernateException: No Session found for current thread 
org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106)
org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1014)

In case of a simpleCommandBus (with the transaction manager) it works like charm. 
I assume this is occurring coz the transaction manager isn't attached to the unit of work in the distributed case or am I doing it wrong?

The DistributedCommandBus uses a “localSegment” that handles the commands for the local node. You can specify a SimpleCommandBus (with transaction manager) there. That’s why the DistributedCommandBus in itself doesn’t have a transaction manager.

Cheers,

Allard

Thanks Allard. Got that working by adding the command bus to the connector as you said!

`
<axon:command-bus id=“simpleCommandBus” transaction-manager=“transactionManager”/>

<beans:bean id=“jGroupsConnector”
class=“org.axonframework.commandhandling.distributed.jgroups.JGroupsConnectorFactoryBean”>
<beans:property name=“configuration” value=“tcp_gossip.xml”/>
<beans:property name=“clusterName” value=“myCluster”/>
<beans:property name=“loadFactor” value=“10”/>
<beans:property name=“localSegment” ref=“simpleCommandBus”/>
</beans:bean>
`