Narayana 5:The premier open source
transaction managerJBug NCL: 12th May 2015
TOM JENKINSON
Agenda● Why you need a transaction manager● Using Narayana inside containers● New features in Narayana 5
Why you need a transaction manager - a brief revision course
My bank Your bank
Transactions - why?
My bank account Your bank account
?
The properties of a transaction
There are many types of transaction models, they generally revolve around adherence to and relaxation of the so-called ACID properties:● Atomicity● Consistency● Isolation● Durability
Transaction APIs
● Specifications:○ JSR-907 JTA 1.2○ OMG OTS 1.1○ OASIS WS-AT 1.2○ OASIS WS-BA 1.2○ X/Open TM○ rest-* REST-AT 2.0 draft 8
● Related:○ XA○ X/Open ATMI
Transaction Manager
(Narayana)
Resource Manager(PostGres,
HornetQ, etc)
Application Programs (you)
XA
JTAJDBC JMS
X/Open DTP
Recovery Manager
Transaction Log
2PC protocolXAResource xar1 = . . .XAResource xar2 = . . . TM.begin();
TM.enlist(xar1);xar1.start(xid1);
TM.enlist(xar2);xar2.start(xid2);
“xar1”.op(...);“xar2”.op(...);
TM.delist(xar1);xar1.end(xid1);
TM.delist(xar2);xar2.end(xid2);
TM.commit();xar1.prepare(xid1);xar2.prepare(xid2);xar1.commit(xid1);xar2.commit(xid2);
Narayana proprietary APIs
● TxCore● TXoJ● Compensations Framework● STM● Utilities:
○ TransactionalDriver○ Tooling to query the transaction log
Other terms
Transaction types:● Global● Distributed● LocalRecovery:● Bottom-up● Top-down
Using Narayana inside containers
WildFly, Undertow, Docker, Tomcat
WildFly
Fully integrated into WFLY● Provides JTA 1.2/JTS implementation● Provides REST-AT coordinator● Provides WS-AT/BA coordinator● Can be extended to provide an XATMI backend
for C applications
Docker
Docker files for RTS and XTS:https://github.com/Gytis/jboss-dockerfiles-narayana/tree/master-xts-and-rts-imagesDocker files for JTS:https://github.com/Gytis/narayana-dockerhttps://github.com/Gytis/quickstart/tree/master-JBTM-2296/jts-docker
REST-AT and Undertow
Start up a REST-AT coordinator in 3 lines!org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer server =
new org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer();
server.deploy(new org.jboss.jbossts.star.service.TMApplication(), "/");
server.start(Undertow.builder().addHttpListener(8080, "localhost"));
JTA in Tomcat
We have two approaches for this1. Tight integration into Tomcat structure2. Running within the IronJacamar embedded
containerhttps://github.com/jbosstm/quickstart/tree/master/jca-and-tomcat
New features in Narayana 5
Compensations Framework, NoSQL, STM
Compensations FrameworkProvides JTA 1.2. like API:● @Compensatable● @TxCompensate● @TxConfirmWorks both locally and remotelyCurrently does not support recoveryhttp://jbossts.blogspot.co.uk/2013/05/compensating-transactions-when-acid-is.html
NoSQL
In development● Atomic● Eventually consistent● Relaxes isolation● DurableUpdates to documents add in transactional data
STM
A concurrency model for editing shared stateBroadly speaking can be broken into:● Optimistic Concurrency Control● Pessimistic Concurrency ControlThe difference is when locks are checkedTypically you have relaxed durability
Other things we are working on
We have a prototype of a data-grid transaction logWe are coming up against CAP theorum for when to elect a recovery manager
Questions? Links!
Our site: http://narayana.ioOur code: https://github.com/jbosstm/Read our opinions: http://jbossts.blogspot.co.uk/Chat to us: http://webchat.freenode.net/?channels=jbosstsQuestion us: https://developer.jboss.org/en/jbosstm/