SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Compensating Transactions:
When ACID is Too Much
Dr Paul Robinson
paul.robinson@redhat.com
@pfrobinson
Agenda
•  Background
•  Non-transactional resources
•  Cross-domain distributed transactions
•  Long-lived transactions
•  What we have today & planned
•  Getting started
ACID Transactions
Positives
•  Strong guarantees
•  Tolerate (certain) failures
•  Easy API to develop against
Negatives
•  Blocking
•  Can reduce throughput
•  Requires two-phase aware resources
•  Tight-coupling
ACID transactions
not suitable?
Don’t give up on transactions
altogether!
Extended Transactions
•  Umbrella term
•  Alternative to ACID
•  Relaxes some ACID properties
Guarantees
None ACIDExtended
Compensation-based
Transactions
•  Based on Sagas
•  Academic research from 1987
•  ACID vs Compensation-based transactions
•  ACID
•  Phase <=1: acquire locks & log
•  Phase 2: commit/rollback changes
•  Compensation-based
•  Phase <=1: commit changes & log
•  Phase 2: confirm? / compensate change
Hang on….
What effect does this have on
Isolation and Consistency?
Looks a bit dubious to me!
Isolation: ACID
Isolation: Compensations
Previous Support in Narayana
•  WS-BusinessActivity
•  Oasis Web Services standard
•  Standardizes
•  Message format
•  State machine
•  No API
•  Problems?
•  Web services only
•  Low-level API
Compensations API
•  JTA-like API
•  Application API only
•  Maybe AS and RM in future
•  Interop with JTA 1.2
•  Transport Neutral
Onto the examples…
Non-Transactional Resources
•  Transactional Resources
•  Participate in a two-phase protocol
•  Prepare and later commit/rollback
•  Non-transactional resources
•  Can’t participate in a two-phase protocol
Compensation-based transaction is an option
Code Example
•  Ecommerce site, selling books
•  Coordinates:
•  Updating databases
•  Dispatching package
Service
public class BookService {
 
    @Inject
    PackageDispatcher packageDispatcher ;
 
    @Compensatable
    public void buyBook(String item, String address) {
 
        packageDispatcher.dispatch(item, address);
        //other activities, such as updating inventory and charging the customer
    }
}
Non-transactional Resource
public class PackageDispatcher {
 
    @Inject
    OrderData orderData;
 
    @TxCompensate(RecallPackage.class)
    public void dispatch(String item, String address) {
 
        orderData.setAddress(address);
        orderData.setItem(item);
        //Dispatch the package
    }
}
Data
@CompensationScoped
public class OrderData implements Serializable {
 
    private String item;
    private String address;
    ...
}
Compensation Handler
public class RecallPackage implements CompensationHandler {
 
    @Inject
    OrderData orderData;
 
    @Override
    public void compensate() {
        //Recall the package somehow
    }
}
Cross-Domain Distributed
Transactions
•  Distribution => Increased chance of failure
•  Use transactions!
•  Distribution => Increased latency
•  Maybe not ACID transactions then
•  Cross-domain => loose coupling
•  ACID transactions => tight-coupling
Compensation-based transaction is an option
Code Example
•  Travel Agent
•  Coordinates:
•  Booking of a Taxi
•  Booking of a Hotel
•  Taxi and Hotel Service are remote Web Services
•  WS-BA
Client
public class Client {
@Compensatable
public void makeBooking() {
// Lookup Hotel and Taxi Web Service ports here...
hotelService.makeBooking("Double", "paul.robinson@redhat.com");
taxiService.makeBooking("Newcastle", "paul.robinson@redhat.com");
}
}
Service@WebService
public class HotelService {
@Inject BookingData bookingData;
@Compensatable(MANDATORY)
@TxCompensate(CancelBooking.class)
@TxConfirm(ConfirmBooking.class)
@Transactional(REQUIRES_NEW)
@WebMethod
public void makeBooking(String item, String user) {
//Update the database to mark the booking as pending…
bookingData.setBookingID("the id of the booking goes here");
}
}
Confirmation Handler
public class ConfirmBooking implements ConfirmationHandler {
@Inject
BookingData bookingData;
@Transactional(REQUIRES_NEW)
public void confirm() {
//Confirm order for bookingData.getBookingID() in Database (in a new JTA transaction)
}
}
Compensation Handler
public class CancelBooking implements CompensationHandler {
@Inject
BookingData bookingData;
@Transactional(REQUIRES_NEW)
public void compensate() {
//Cancel order for bookingData.getBookingID() in Database (in a new JTA transaction)
}
}
Long Lived Transactions (LLT)
•  ACID Transactions => all or nothing
•  OK for short lived transactions (SLT)
•  Failure in LLT leads to significant loss of work
•  Compensation-based Transactions
•  Split work into many SLT
•  Find alternative if one fails
•  Compensate all if no alternative
Code Example
•  Travel Agent
•  Coordinates:
•  Hotel service
•  2 Taxi Services
•  Aim to book 1xHotel & 1xTaxi
•  Hotel booking is important
Travel Agent Client
public class Agent {
@Inject ...
@Compensatable
public void makeBooking(String email, String room, String dest) throws BookingException {
hotelService.makeBooking(room, email);
try {
taxi1Service.makeBooking(dest, email);
} catch (BookingException e) {
taxi2Service.makeBooking(dest, email);
}
}
}
What we Have Today
•  Initial version of the API
•  @Compensatable
•  @CompensationScoped
•  LLT
•  Distribution over WS-BA
•  Quickstarts
•  All today’s examples
•  Blog post series
•  Available in:
•  Narayana 5.0.0.M4
•  WildFly 8.0.0.Alpha4
What we Have Planned
•  Support more complex use-cases
•  Feedback driven
•  Recovery
•  @CompensationScoped
•  JTA interop
•  EJB support
•  Specification
•  Throughput comparisons
•  2PC participants
•  NoSQL RM integration
Getting Started
•  Explore the quickstarts
•  http://github.com/jbosstm/quickstart/
•  Give feedback
•  http://community.jboss.org/en/jbosstm
•  Track issues
•  http://issues.jboss.org/browse/JBTM
•  TXFramework component
•  Subscribe to Blog
•  http://jbossts.blogspot.co.uk/
•  Contact me
•  paul.robinson@redhat.com, @pfrobinson

Weitere ähnliche Inhalte

Ähnlich wie Compensating Transactions: When ACID is too much

RedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedis Labs
 
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...Chris Richardson
 
Geode Transactions by Swapnil Bawaskar
Geode Transactions by Swapnil BawaskarGeode Transactions by Swapnil Bawaskar
Geode Transactions by Swapnil BawaskarPivotalOpenSourceHub
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
 
"An introduction to object-oriented programming for those who have never done...
"An introduction to object-oriented programming for those who have never done..."An introduction to object-oriented programming for those who have never done...
"An introduction to object-oriented programming for those who have never done...Fwdays
 
Dont call me cache java version
Dont call me cache java versionDont call me cache java version
Dont call me cache java versionAvisi B.V.
 
Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...
Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...
Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...confluent
 
Grails transactions
Grails   transactionsGrails   transactions
Grails transactionsHusain Dalal
 
Solidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesSolidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesGene Leybzon
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestPavan Chitumalla
 
Solid Software Design Principles
Solid Software Design PrinciplesSolid Software Design Principles
Solid Software Design PrinciplesJon Kruger
 
Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...
Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...
Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...James Coplien
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchainBellaj Badr
 
Refactoring - improving the smell of your code
Refactoring - improving the smell of your codeRefactoring - improving the smell of your code
Refactoring - improving the smell of your codevmandrychenko
 

Ähnlich wie Compensating Transactions: When ACID is too much (20)

Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Clean Architecture @ Taxibeat
Clean Architecture @ TaxibeatClean Architecture @ Taxibeat
Clean Architecture @ Taxibeat
 
RedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis codeRedisConf18 - Writing modular & encapsulated Redis code
RedisConf18 - Writing modular & encapsulated Redis code
 
CDI in JEE6
CDI in JEE6CDI in JEE6
CDI in JEE6
 
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...
ArchSummit Shenzhen - Using sagas to maintain data consistency in a microserv...
 
Geode Transactions by Swapnil Bawaskar
Geode Transactions by Swapnil BawaskarGeode Transactions by Swapnil Bawaskar
Geode Transactions by Swapnil Bawaskar
 
Geode transactions
Geode transactionsGeode transactions
Geode transactions
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
"An introduction to object-oriented programming for those who have never done...
"An introduction to object-oriented programming for those who have never done..."An introduction to object-oriented programming for those who have never done...
"An introduction to object-oriented programming for those who have never done...
 
Dont call me cache java version
Dont call me cache java versionDont call me cache java version
Dont call me cache java version
 
Code smells and remedies
Code smells and remediesCode smells and remedies
Code smells and remedies
 
Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...
Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...
Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) K...
 
Grails transactions
Grails   transactionsGrails   transactions
Grails transactions
 
Solidity Security and Best Coding Practices
Solidity Security and Best Coding PracticesSolidity Security and Best Coding Practices
Solidity Security and Best Coding Practices
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at Pinterest
 
Solid Software Design Principles
Solid Software Design PrinciplesSolid Software Design Principles
Solid Software Design Principles
 
Transaction design patterns
Transaction design patternsTransaction design patterns
Transaction design patterns
 
Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...
Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...
Real Object-Oriented Programming: Empirically Validated Benefits of the DCI P...
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchain
 
Refactoring - improving the smell of your code
Refactoring - improving the smell of your codeRefactoring - improving the smell of your code
Refactoring - improving the smell of your code
 

Mehr von JBUG London

London JBUG April 2015 - Performance Tuning Apps with WildFly Application Server
London JBUG April 2015 - Performance Tuning Apps with WildFly Application ServerLondon JBUG April 2015 - Performance Tuning Apps with WildFly Application Server
London JBUG April 2015 - Performance Tuning Apps with WildFly Application ServerJBUG London
 
WebSocketson WildFly
WebSocketson WildFly WebSocketson WildFly
WebSocketson WildFly JBUG London
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9JBUG London
 
Introduction to PicketLink
Introduction to PicketLinkIntroduction to PicketLink
Introduction to PicketLinkJBUG London
 
Extending WildFly
Extending WildFlyExtending WildFly
Extending WildFlyJBUG London
 
What's New in Infinispan 6.0
What's New in Infinispan 6.0What's New in Infinispan 6.0
What's New in Infinispan 6.0JBUG London
 
London JBUG - Connecting Applications Everywhere with JBoss A-MQ
London JBUG - Connecting Applications Everywhere with JBoss A-MQLondon JBUG - Connecting Applications Everywhere with JBoss A-MQ
London JBUG - Connecting Applications Everywhere with JBoss A-MQJBUG London
 
Easy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDEEasy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDEJBUG London
 
jBPM5 - The Evolution of BPM Systems
jBPM5 - The Evolution of BPM SystemsjBPM5 - The Evolution of BPM Systems
jBPM5 - The Evolution of BPM SystemsJBUG London
 
Arquillian - Integration Testing Made Easy
Arquillian - Integration Testing Made EasyArquillian - Integration Testing Made Easy
Arquillian - Integration Testing Made EasyJBUG London
 
Infinispan from POC to Production
Infinispan from POC to ProductionInfinispan from POC to Production
Infinispan from POC to ProductionJBUG London
 
Hibernate OGM - JPA for Infinispan and NoSQL
Hibernate OGM - JPA for Infinispan and NoSQLHibernate OGM - JPA for Infinispan and NoSQL
Hibernate OGM - JPA for Infinispan and NoSQLJBUG London
 
JBoss jBPM, the future is now for all your Business Processes by Eric Schabell
JBoss jBPM, the future is now for all your Business Processes by Eric SchabellJBoss jBPM, the future is now for all your Business Processes by Eric Schabell
JBoss jBPM, the future is now for all your Business Processes by Eric SchabellJBUG London
 
JBoss AS7 by Matt Brasier
JBoss AS7 by Matt BrasierJBoss AS7 by Matt Brasier
JBoss AS7 by Matt BrasierJBUG London
 

Mehr von JBUG London (14)

London JBUG April 2015 - Performance Tuning Apps with WildFly Application Server
London JBUG April 2015 - Performance Tuning Apps with WildFly Application ServerLondon JBUG April 2015 - Performance Tuning Apps with WildFly Application Server
London JBUG April 2015 - Performance Tuning Apps with WildFly Application Server
 
WebSocketson WildFly
WebSocketson WildFly WebSocketson WildFly
WebSocketson WildFly
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
 
Introduction to PicketLink
Introduction to PicketLinkIntroduction to PicketLink
Introduction to PicketLink
 
Extending WildFly
Extending WildFlyExtending WildFly
Extending WildFly
 
What's New in Infinispan 6.0
What's New in Infinispan 6.0What's New in Infinispan 6.0
What's New in Infinispan 6.0
 
London JBUG - Connecting Applications Everywhere with JBoss A-MQ
London JBUG - Connecting Applications Everywhere with JBoss A-MQLondon JBUG - Connecting Applications Everywhere with JBoss A-MQ
London JBUG - Connecting Applications Everywhere with JBoss A-MQ
 
Easy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDEEasy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDE
 
jBPM5 - The Evolution of BPM Systems
jBPM5 - The Evolution of BPM SystemsjBPM5 - The Evolution of BPM Systems
jBPM5 - The Evolution of BPM Systems
 
Arquillian - Integration Testing Made Easy
Arquillian - Integration Testing Made EasyArquillian - Integration Testing Made Easy
Arquillian - Integration Testing Made Easy
 
Infinispan from POC to Production
Infinispan from POC to ProductionInfinispan from POC to Production
Infinispan from POC to Production
 
Hibernate OGM - JPA for Infinispan and NoSQL
Hibernate OGM - JPA for Infinispan and NoSQLHibernate OGM - JPA for Infinispan and NoSQL
Hibernate OGM - JPA for Infinispan and NoSQL
 
JBoss jBPM, the future is now for all your Business Processes by Eric Schabell
JBoss jBPM, the future is now for all your Business Processes by Eric SchabellJBoss jBPM, the future is now for all your Business Processes by Eric Schabell
JBoss jBPM, the future is now for all your Business Processes by Eric Schabell
 
JBoss AS7 by Matt Brasier
JBoss AS7 by Matt BrasierJBoss AS7 by Matt Brasier
JBoss AS7 by Matt Brasier
 

Kürzlich hochgeladen

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Compensating Transactions: When ACID is too much

  • 1.
  • 2. Compensating Transactions: When ACID is Too Much Dr Paul Robinson paul.robinson@redhat.com @pfrobinson
  • 3. Agenda •  Background •  Non-transactional resources •  Cross-domain distributed transactions •  Long-lived transactions •  What we have today & planned •  Getting started
  • 4. ACID Transactions Positives •  Strong guarantees •  Tolerate (certain) failures •  Easy API to develop against Negatives •  Blocking •  Can reduce throughput •  Requires two-phase aware resources •  Tight-coupling
  • 6. Don’t give up on transactions altogether!
  • 7. Extended Transactions •  Umbrella term •  Alternative to ACID •  Relaxes some ACID properties Guarantees None ACIDExtended
  • 8. Compensation-based Transactions •  Based on Sagas •  Academic research from 1987 •  ACID vs Compensation-based transactions •  ACID •  Phase <=1: acquire locks & log •  Phase 2: commit/rollback changes •  Compensation-based •  Phase <=1: commit changes & log •  Phase 2: confirm? / compensate change
  • 9. Hang on…. What effect does this have on Isolation and Consistency? Looks a bit dubious to me!
  • 12. Previous Support in Narayana •  WS-BusinessActivity •  Oasis Web Services standard •  Standardizes •  Message format •  State machine •  No API •  Problems? •  Web services only •  Low-level API
  • 13. Compensations API •  JTA-like API •  Application API only •  Maybe AS and RM in future •  Interop with JTA 1.2 •  Transport Neutral
  • 15. Non-Transactional Resources •  Transactional Resources •  Participate in a two-phase protocol •  Prepare and later commit/rollback •  Non-transactional resources •  Can’t participate in a two-phase protocol Compensation-based transaction is an option
  • 16. Code Example •  Ecommerce site, selling books •  Coordinates: •  Updating databases •  Dispatching package
  • 17. Service public class BookService {       @Inject     PackageDispatcher packageDispatcher ;       @Compensatable     public void buyBook(String item, String address) {           packageDispatcher.dispatch(item, address);         //other activities, such as updating inventory and charging the customer     } }
  • 18. Non-transactional Resource public class PackageDispatcher {       @Inject     OrderData orderData;       @TxCompensate(RecallPackage.class)     public void dispatch(String item, String address) {           orderData.setAddress(address);         orderData.setItem(item);         //Dispatch the package     } }
  • 19. Data @CompensationScoped public class OrderData implements Serializable {       private String item;     private String address;     ... }
  • 20. Compensation Handler public class RecallPackage implements CompensationHandler {       @Inject     OrderData orderData;       @Override     public void compensate() {         //Recall the package somehow     } }
  • 21. Cross-Domain Distributed Transactions •  Distribution => Increased chance of failure •  Use transactions! •  Distribution => Increased latency •  Maybe not ACID transactions then •  Cross-domain => loose coupling •  ACID transactions => tight-coupling Compensation-based transaction is an option
  • 22. Code Example •  Travel Agent •  Coordinates: •  Booking of a Taxi •  Booking of a Hotel •  Taxi and Hotel Service are remote Web Services •  WS-BA
  • 23. Client public class Client { @Compensatable public void makeBooking() { // Lookup Hotel and Taxi Web Service ports here... hotelService.makeBooking("Double", "paul.robinson@redhat.com"); taxiService.makeBooking("Newcastle", "paul.robinson@redhat.com"); } }
  • 24. Service@WebService public class HotelService { @Inject BookingData bookingData; @Compensatable(MANDATORY) @TxCompensate(CancelBooking.class) @TxConfirm(ConfirmBooking.class) @Transactional(REQUIRES_NEW) @WebMethod public void makeBooking(String item, String user) { //Update the database to mark the booking as pending… bookingData.setBookingID("the id of the booking goes here"); } }
  • 25. Confirmation Handler public class ConfirmBooking implements ConfirmationHandler { @Inject BookingData bookingData; @Transactional(REQUIRES_NEW) public void confirm() { //Confirm order for bookingData.getBookingID() in Database (in a new JTA transaction) } }
  • 26. Compensation Handler public class CancelBooking implements CompensationHandler { @Inject BookingData bookingData; @Transactional(REQUIRES_NEW) public void compensate() { //Cancel order for bookingData.getBookingID() in Database (in a new JTA transaction) } }
  • 27. Long Lived Transactions (LLT) •  ACID Transactions => all or nothing •  OK for short lived transactions (SLT) •  Failure in LLT leads to significant loss of work •  Compensation-based Transactions •  Split work into many SLT •  Find alternative if one fails •  Compensate all if no alternative
  • 28. Code Example •  Travel Agent •  Coordinates: •  Hotel service •  2 Taxi Services •  Aim to book 1xHotel & 1xTaxi •  Hotel booking is important
  • 29. Travel Agent Client public class Agent { @Inject ... @Compensatable public void makeBooking(String email, String room, String dest) throws BookingException { hotelService.makeBooking(room, email); try { taxi1Service.makeBooking(dest, email); } catch (BookingException e) { taxi2Service.makeBooking(dest, email); } } }
  • 30. What we Have Today •  Initial version of the API •  @Compensatable •  @CompensationScoped •  LLT •  Distribution over WS-BA •  Quickstarts •  All today’s examples •  Blog post series •  Available in: •  Narayana 5.0.0.M4 •  WildFly 8.0.0.Alpha4
  • 31. What we Have Planned •  Support more complex use-cases •  Feedback driven •  Recovery •  @CompensationScoped •  JTA interop •  EJB support •  Specification •  Throughput comparisons •  2PC participants •  NoSQL RM integration
  • 32. Getting Started •  Explore the quickstarts •  http://github.com/jbosstm/quickstart/ •  Give feedback •  http://community.jboss.org/en/jbosstm •  Track issues •  http://issues.jboss.org/browse/JBTM •  TXFramework component •  Subscribe to Blog •  http://jbossts.blogspot.co.uk/ •  Contact me •  paul.robinson@redhat.com, @pfrobinson