transactions in your micro-services architecture · transactions in your micro-services...
TRANSCRIPT
![Page 1: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/1.jpg)
Transactions in your micro-services architecture
Rudy De Busscher
Dawn Parzych (CatchPoint)
![Page 2: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/2.jpg)
What?
• Transaction and Micro-Services
• MicroProfile LRA (Long Running Actions)
• Demo
![Page 3: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/3.jpg)
Rudy De Busscher• Payara
• Service team
• Involved in• Committer of MicroProfile • Committer in Eclipse EE4J groups • Java EE Security API Expert group member
@rdebusscher
https://blog.payara.fish/ https://www.atbash.be
![Page 4: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/4.jpg)
Transaction
• Typical concept from the ‘Monolith’
• Start - End
• Typical short - to avoid locks
![Page 5: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/5.jpg)
Distributed Transaction
• Multiple datasources - Distributed
• XA transactions
• 2 Phase Commit
• Not scalable
• Locks
![Page 6: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/6.jpg)
To be ACID or not• Atomicity: All or Nothing
• Consistency: All values are aligned
• Isolation: Different transactions can’t see ‘temporal’ values
• Durable: Reliably Stored
• CAP Theorem
• Consistency - Availability - Partitioning
![Page 7: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/7.jpg)
Long Running Transactions
• Multiple Datasource
• Several steps over long period
• Single Unit of Work?
Web Services Journal
![Page 8: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/8.jpg)
Example
• Book Flight
• Book Hotel
• Payment
AltexSoft
![Page 9: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/9.jpg)
Microservice world
• No Atomicity
• Eventual Consistency
• No Isolation
• DurableKumuluzEE
![Page 10: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/10.jpg)
SAGA Pattern
![Page 11: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/11.jpg)
• Optimizing Enterprise Java for a Micro-services Architecture
• Based on some Java EE (Jakarta EE) specs
![Page 12: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/12.jpg)
MP Long Running Action
• First release candidate available.
• Finalised in coming months.
![Page 13: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/13.jpg)
MicroProfile LRA
• Long Running Actions
• Features
• Loose coupling
• Guaranteed a globally consistent outcome
• Compensatable actions (SAGAs)
![Page 14: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/14.jpg)
LRA Components
JAX-RSresource JAX-RS
resourceJAX-RSresource
Coordinator
Participant Participant
Callback
Enlist
Participant
![Page 15: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/15.jpg)
DEMO
![Page 16: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/16.jpg)
Some Key Code concepts
• @LRA
• LRA Level / defines transaction
• @Compensate
• Participant level: Required
• @Complete
• Participant level
• LRA ID ( = URI)
• Uniquely defines the Long Running Action (transaction)
• Propagated through Header
![Page 17: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/17.jpg)
DEMO
Service A
Service B
Service C
Start
End
Distributed
![Page 18: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/18.jpg)
Returning Participant Status• Immediate
• Return type ParticipantStatus, void
• Asynchronous return • Return CompletableFuture<ParticipantStatus>
• Idempotent @Complete/@Compensate • Return type ParticipantStatus • ParticipantStatus.Completing / ParticipantStatus.Compensating
• Through @Status method • First call to @Complete/@Compensate • Following calls to @Status
![Page 19: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/19.jpg)
TimeOut
• By Default, LRA runs forever • But also by Default, immediately closed
• Closed explicitly (end=true) • Define a timeout -> cancelled / all participants
compensated.
![Page 20: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/20.jpg)
Remove Participant
• @Leave • Remove Participant from LRA • Developer responsible for cleanup
• No @Compensate/@Complete/@Status called
![Page 21: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/21.jpg)
Feedback Final status
• @AfterLRA • What was the final outcome
![Page 22: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/22.jpg)
Store LRA info
• LRA only performs orchestration • Participant needs to keep track of LRA • Store LRA Id as part of your business data • Extension
• LRAData • ParticipantData
![Page 23: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/23.jpg)
Takeaways
• Classic approach for Transactions and Long Running Action not applicable for micro-services
• MicroProfile LRA uses Compensatable actions
• Loosely coupled on top of JAX-RS resources
• Specification : Almost final
![Page 24: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/24.jpg)
Code
• Project https://github.com/eclipse/microprofile-lra
• Demo code • https://github.com/rdebusscher/mp-lra-demo
![Page 25: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/25.jpg)
Q & A
![Page 26: Transactions in your micro-services architecture · Transactions in your micro-services architecture Rudy De Busscher Dawn Parzych (CatchPoint) What? ... • Service team • Involved](https://reader033.vdocument.in/reader033/viewer/2022060215/5f05c0ba7e708231d41487fd/html5/thumbnails/26.jpg)
Download the open source software: https://payara.fish/downloads
Need support for the Payara Platform? https://payara.fish/support