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?