Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cloud-Native Development and Migration to Jakarta EE

You're reading from   Cloud-Native Development and Migration to Jakarta EE Transform your legacy Java EE project into a cloud-native application

Arrow left icon
Product type Paperback
Published in Oct 2023
Publisher Packt
ISBN-13 9781837639625
Length 198 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
David Vlijmincx David Vlijmincx
Author Profile Icon David Vlijmincx
David Vlijmincx
Ron Veen Ron Veen
Author Profile Icon Ron Veen
Ron Veen
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Part 1: History of Java EE and Jakarta EE
2. Chapter 1: The History of Enterprise Java FREE CHAPTER 3. Chapter 2: Introducing the Cargo Tracker Application 4. Part 2: Modern Jakarta EE
5. Chapter 3: Moving from Java EE to Jakarta EE 6. Chapter 4: Modernizing Your Application with the Latest Features 7. Chapter 5: Making Your Application Testable 8. Part 3: Embracing the Cloud
9. Chapter 6: Introduction to Containers and Docker 10. Chapter 7: Meet Kubernetes 11. Chapter 8: What Is Cloud Native? 12. Chapter 9: Deploying Jakarta EE Applications in the Cloud 13. Chapter 10: Introducing MicroProfile 14. Index 15. Other Books You May Enjoy Appendix A: Java EE to Jakarta EE names
1. Appendix B: As a Service

MicroProfile Fault Tolerance

So, we have our service configured and we can check its health. The next step for a microservice to become cloud-native is adding some resilience. The service should be able to self-heal within certain limits.

There are six annotations available within MicroProfile Fault Tolerance that can help make your service more robust:

  • @Asynchronous
  • @Retry
  • @Timeout
  • @Bulkhead
  • @CircuitBreaker
  • @Fallback

It is good to know that these annotations can be added to both CDI beans and public methods within those beans. Under the hood, they are implemented via interceptors.

@Asynchronous

@Asynchronous adds, well, asynchronous behavior to the method it annotates. It wraps them into a method that returns CompletableStage on which the other fault tolerance annotation can be applied.

@Asynchronous allows your code to run concurrently. Let’s have a look at an example:

@Inject
// is annoted with @Asynchronous
private CustomerDetailsService...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image