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”/>



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:

public void handle(final CreateUserCommand command) {
Person person = new Person();
person.setCountry( command.getCountry());

Session session = this.sessionFactory.getCurrentSession();

But I keep getting this exception:

org.hibernate.HibernateException: No Session found for current thread 

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.



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”
<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”/>