DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Data
  4. Developing Resilient Microservices With Istio and MicroProfile

Developing Resilient Microservices With Istio and MicroProfile

In this post, we give a quick rundown of how developers can go about creating and working with resilient microservices using these two popular frameworks.

Niklas Heidloff user avatar by
Niklas Heidloff
CORE ·
Mar. 13, 19 · Tutorial
Like (2)
Save
Tweet
Share
7.09K Views

Join the DZone community and get the full member experience.

Join For Free

as stated in the reactive manifesto , cloud-native reactive applications need to be resilient:

the system stays responsive in the face of failure. this applies not only to highly-available, mission-critical systems — any system that is not resilient will be unresponsive after a failure. resilience is achieved by replication, containment, isolation ...

in distributed systems, you need to design for failure. for example, microservices which invoke other microservices must be intelligent enough to continue to work even if some of their dependencies are currently not available.

there are several different ways to build resilient service meshes with istio, for example via circuit breakers and retries .

the istio functionality for resilient cloud-native applications is generic and independent from the implementation of the microservices. however, in some cases, the handling of failures depends on the business logic of the applications, which is why this needs to be implemented in the microservices.

i have open sourced a simple sample that demonstrates this functionality. the application uses a vue.js front-end that displays articles. the service 'web-api' implements the bff (backend for front-end) pattern. the web application accesses the 'web-api' service which invokes both the 'articles' and 'authors' services.

if you want to run this sample , get the code from github.

make sure that you've set up your development environment and that you have installed the prerequisites . after this, invoke the following commands to deploy the microservices.

$ git clone https://github.com/nheidloff/cloud-native-starter.git
$ cd cloud-native-starter
$ scripts/deploy-articles-java-jee.sh
$ scripts/deploy-web-api-java-jee.sh
$ scripts/deploy-authors-nodejs.sh
$ scripts/deploy-web-app-vuejs.sh
$ scripts/show-urls.sh

after running the scripts above, you will get a list of all urls in the terminal. the web application can be opened via http://your-minikube-ip:31380 . the initial page shows the five most recent articles including information about the authors.

now let's delete the authors service:

$ scripts/delete-authors-nodejs.sh

when you refresh the web application, it will still display five articles, but this time without the information about the authors. while the web application cannot display the complete information anymore, in this simple scenario it still makes sense to display the titles and links of the articles.

the implementation of this behavior has been done in service.java :

try {
   author author = dataaccessmanager.getauthorsdataaccess().getauthor(corearticle.author);
   article.authorblog = author.blog;
   article.authortwitter = author.twitter;
} catch (noconnectivity | nonexistentauthor e) {    
   article.authorblog = "";
   article.authortwitter = "";
}

next, let's delete the articles service:

$ scripts/delete-web-api-java-jee.sh

when you refresh the web application, you'll notice that the same five articles are still displayed. that's because, in this trivial scenario, the 'web-api' service caches the last read articles. if the 'articles' service is not available, it simply returns the information from the cache.

i'm using the eclipse microprofile fallback annotation. in this case, a fallback method is invoked if the original method throws an exception.

@fallback(fallbackmethod = "fallbacknoarticlesservice")
public list<article> getarticles() throws nodataaccess {
   list<corearticle> corearticles = new arraylist<corearticle>();   
   try {
      corearticles = dataaccessmanager.getarticlesdataaccess().getarticles(5);                          
   } catch (noconnectivity e) {
      system.err.println("com.ibm.webapi.business.getarticles: cannot connect to articles service");
      throw new nodataaccess(e);
   }
...
}   
...
public list<article> fallbacknoarticlesservice() {
   system.err.println("com.ibm.webapi.business.fallbacknoarticlesservice: cannot connect to articles service");
   if (lastreadarticles == null) lastreadarticles = new arraylist<article>();
      return lastreadarticles;
}

read the article microprofile, the microservice programming model made for istio , to learn more about how to build resilient applications with both istio and microprofile.

microservice application Web Service Web application

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Tracking Software Architecture Decisions
  • How To Build a Spring Boot GraalVM Image
  • The Path From APIs to Containers
  • 5 Steps for Getting Started in Deep Learning

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: