Atomikos Transaction management spring boot/spring jams -
i have spring boot application spring jms using defaultmessagelistener container. using atomikos transaction management. on exception message queue roll works fine , messages move out queue, database updates not roll back. have set autoconfigured jtatransactionmanager on defaultmessagecontainerbean. there other configurations required here true global transaction management. using batis database.
public class cuslistener implements messagelistener{ public void onmessage(message message) { //database call catch (exception ex) { throw (new runtimeexception()); } } } @configuration public class listenercontainer{ @bean public defaultmessagelistenercontainer defaultmessagelistenercontainer(connectionfactory queueconnectionfactory,mqqueue queue, messagelistener listener, jtatransactionmanager jtatransactionmanager) { defaultmessagelistenercontainer defaultmessagelistenercontainer = new defaultmessagelistenercontainer(); defaultmessagelistenercontainer.setconnectionfactory(queueconnectionfactory); defaultmessagelistenercontainer.setdestination(queue); defaultmessagelistenercontainer.setmessagelistener(listerner); defaultmessagelistenercontainer.settransactionmanager(jtatransactionmanager); defaultmessagelistenercontainer.setsessiontransacted(true); defaultmessagelistenercontainer.setconcurrency("3-10"); return defaultmessagelistenercontainer; } //other beans declaration passed in method above } @configuration public class planlistenersqlsessfac { @bean(name="sqlsessionfactory") public sqlsessionfactory sqlsessionfactory(@qualifier("datasource") nmcryptodatasourcewrapper datasource) throws exception { } @bean(name="drivermanagerdatasource") public drivermanagerdatasource drivermanagerdatasource() { drivermanagerdatasource drivermanagerdatasource = new drivermanagerdatasource(); return drivermanagerdatasource; }
}
you should use atomikosdatasourcebean datadource.
see documentation : https://www.atomikos.com/bin/view/documentation/configuringjdbc
Comments
Post a Comment