{"id":14485,"date":"2015-11-26T15:41:58","date_gmt":"2015-11-26T14:41:58","guid":{"rendered":"https:\/\/blog.trifork.com\/?p=14485"},"modified":"2015-11-26T15:41:58","modified_gmt":"2015-11-26T14:41:58","slug":"booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch","status":"publish","type":"post","link":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/","title":{"rendered":"Booting your Microservices Architecture with Spring and Netflix: the aftermath"},"content":{"rendered":"<p>On 25 November Trifork hosted a webinar in which I gave a short overview of Spring Cloud and its support for the Netflix OSS stack, focusing on Spring Cloud Config and the support for Netflix\u2019s Eureka, Ribbon and Hystrix.<\/p>\n<p>We&#8217;ve been investigating this stack over the last couple of months and are using parts of it in production already: we have found that a lot of the common concerns that you need to tackle as you&#8217;re moving into a distributed systems architecture are nicely covered and, in many cases, even abstracted by the Spring Cloud platform. In a typical Spring fashion, this allows you as an application developer to focus more on your business logic while letting the framework handle the concerns related to things like accessing shared configuration, working with service registries, handling failing downstream services, etc.<\/p>\n<p>This blog provides you with background info to accompany the webinar, which has been recorded and can be found <a title=\"Spring Cloud webinar recording\" href=\"https:\/\/www.youtube.com\/watch?v=bsMmIWt2iUE&amp;feature=youtu.be\" target=\"_blank\" rel=\"noopener\">on our YouTube channel<\/a>.<br \/>\nThe code has been published <a title=\"webinar sources\" href=\"https:\/\/github.com\/triforkams\/spring-ms-webinar\" target=\"_blank\" rel=\"noopener\">on GitHub<\/a>, as well as the accompanying <a title=\"webinar config repository\" href=\"https:\/\/github.com\/triforkams\/spring-ms-demo-config\" target=\"_blank\" rel=\"noopener\">config repository<\/a>, in case you&#8217;d like to code along with the video.<\/p>\n<p><!--more--><\/p>\n<h3>Overview<\/h3>\n<p>In the demo I basically showcase an application with the following architecture:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-14488\" src=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png\" alt=\"arch\" width=\"364\" height=\"274\" srcset=\"https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png 300w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-768x579.png 768w, https:\/\/trifork.nl\/blog\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1.png 988w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>There&#8217;s two services with a web application fronting them. All three applications act as clients to both the config server as well as Eureka. The calls that the conference web app makes to the downstream services are guarded by Hystrix circuitbreakers. There&#8217;s also a Hystrix dashboard app that can visualize the state of the circuit breakers present in the web app.<\/p>\n<p>All applications can be run from the command line using Spring Boot\u2019s maven plugin: just type \u2018mvn spring-boot:run\u2019. Of course you can also import the projects into your IDE and run them from there, or use one of the other methods available to run Spring Boot-based applications.<\/p>\n<p>After cloning the Git repositories, make sure to first update the config server\u2019s configuration file to point to your local copy of the Git config repository. The code will be in the state that matches the end of the webinar: there are \u2018start\u2019 tags in both repositories if you\u2019d like to reset the code to the state matching the start of the webinar instead.<\/p>\n<h3>Steps taken in the webinar<\/h3>\n<p>The steps shown in the webinar, which you can make for yourself if you reset the code to the \u2018start\u2019 tag, are the following:<\/p>\n<ol>\n<li>Add the spring-cloud-starter-config dependency to the talk-service and inject the \u2018greeting\u2019 configuration property into its controller. I also enabled a \u2018dev\u2019 profile for the talk-service. The greeting key needs to be added to the talk-service.properties in the config repo and the config server needs to be running; after that, you can start the talk-service and it should work.<\/li>\n<li>Add the spring-cloud-starter-eureka dependency to the talk-service and annotate its main class with @EnableDiscoveryClient to have it register itself with Eureka (which needs to be running for that, obviously). Restart the talk-service, and it should show up in the Eureka dashboard. Start the review-service and conference-web apps as well, and they too will show up: you can now access the conference-web app at <a href=\"http:\/\/localhost:8080\/\">http:\/\/localhost:8080\/<\/a>.<\/li>\n<li>Modify the TalkService in the conference-web app to use a HystrixCommand with a fallback method returning cached talks. You should now be able to stop the talk-service and still be able to use the web app. If you start the Hystrix dashboard and connect to the conference-web app (simply access <a href=\"http:\/\/localhost:9000\/hystrix\/monitor?stream=localhost%3A8080%2Fhystrix.stream\">http:\/\/localhost:9000\/hystrix\/monitor?stream=localhost%3A8080%2Fhystrix.stream<\/a>) then you should see the circuit breakers with their status and thread pools.<\/li>\n<\/ol>\n<h3>Where to go from here<\/h3>\n<p>This sample is really just the beginning. Some suggestions on how you can expand the sample with other Spring Cloud solutions (check the <a href=\"http:\/\/projects.spring.io\/spring-cloud\/spring-cloud.html\" target=\"_blank\" rel=\"noopener\">reference docs<\/a> for more details):<\/p>\n<ol>\n<li>Add a dependency to the Spring Cloud Zuul starter and annotate your conference-web\u2019s main class with @EnableZuulProxy. After that, you will be able to access the backing services through the conference web (e.g. at <a href=\"http:\/\/localhost:8080\/talk-service\/talk\">http:\/\/localhost:8080\/talk-service\/talk<\/a>). Note that accessing the talk-service this way will automatically be done through a Hystrix command as well.<\/li>\n<li>Put the Git config repo in your own GitLab or GitHub repo and use <a href=\"http:\/\/cloud.spring.io\/spring-cloud-bus\" target=\"_blank\" rel=\"noopener\">Spring Cloud Bus<\/a> to automatically refresh services when their configuration has changed.<\/li>\n<li>Use <a href=\"http:\/\/cloud.spring.io\/spring-cloud-sleuth\" target=\"_blank\" rel=\"noopener\">Spring Cloud Sleuth<\/a> to add distributed tracing.<\/li>\n<li>Replace Eureka (and optionally the Spring Config server as well) with <a href=\"http:\/\/cloud.spring.io\/spring-cloud-consul\" target=\"_blank\" rel=\"noopener\">Consul<\/a> and see what changes are needed.<\/li>\n<\/ol>\n<p>Speaking of Consul, we\u2019ll be publishing another blog post on using Consul here soon, so make sure to watch this space for updates!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On 25 November Trifork hosted a webinar in which I gave a short overview of Spring Cloud and its support for the Netflix OSS stack, focusing on Spring Cloud Config and the support for Netflix\u2019s Eureka, Ribbon and Hystrix. We&#8217;ve been investigating this stack over the last couple of months and are using parts of [&hellip;]<\/p>\n","protected":false},"author":62,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[10,94],"tags":[],"class_list":["post-14485","post","type-post","status-publish","format-standard","hentry","category-development","category-spring"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Booting your Microservices Architecture with Spring and Netflix: the aftermath - Trifork Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Booting your Microservices Architecture with Spring and Netflix: the aftermath - Trifork Blog\" \/>\n<meta property=\"og:description\" content=\"On 25 November Trifork hosted a webinar in which I gave a short overview of Spring Cloud and its support for the Netflix OSS stack, focusing on Spring Cloud Config and the support for Netflix\u2019s Eureka, Ribbon and Hystrix. We&#8217;ve been investigating this stack over the last couple of months and are using parts of [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/\" \/>\n<meta property=\"og:site_name\" content=\"Trifork Blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-26T14:41:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png\" \/>\n<meta name=\"author\" content=\"Joris Kuipers\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joris Kuipers\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/\",\"url\":\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/\",\"name\":\"Booting your Microservices Architecture with Spring and Netflix: the aftermath - Trifork Blog\",\"isPartOf\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png\",\"datePublished\":\"2015-11-26T14:41:58+00:00\",\"author\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/265bd41e503f7176742258a927de598b\"},\"breadcrumb\":{\"@id\":\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#primaryimage\",\"url\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png\",\"contentUrl\":\"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/trifork.nl\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Booting your Microservices Architecture with Spring and Netflix: the aftermath\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/trifork.nl\/blog\/#website\",\"url\":\"https:\/\/trifork.nl\/blog\/\",\"name\":\"Trifork Blog\",\"description\":\"Keep updated on the technical solutions Trifork is working on!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/trifork.nl\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/265bd41e503f7176742258a927de598b\",\"name\":\"Joris Kuipers\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9ab8da0d60582bad84342d4602d23dbd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9ab8da0d60582bad84342d4602d23dbd?s=96&d=mm&r=g\",\"caption\":\"Joris Kuipers\"},\"sameAs\":[\"http:\/\/www.trifork.nl\"],\"url\":\"https:\/\/trifork.nl\/blog\/author\/jorisk\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Booting your Microservices Architecture with Spring and Netflix: the aftermath - Trifork Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/","og_locale":"en_US","og_type":"article","og_title":"Booting your Microservices Architecture with Spring and Netflix: the aftermath - Trifork Blog","og_description":"On 25 November Trifork hosted a webinar in which I gave a short overview of Spring Cloud and its support for the Netflix OSS stack, focusing on Spring Cloud Config and the support for Netflix\u2019s Eureka, Ribbon and Hystrix. We&#8217;ve been investigating this stack over the last couple of months and are using parts of [&hellip;]","og_url":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/","og_site_name":"Trifork Blog","article_published_time":"2015-11-26T14:41:58+00:00","og_image":[{"url":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png","type":"","width":"","height":""}],"author":"Joris Kuipers","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joris Kuipers","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/","url":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/","name":"Booting your Microservices Architecture with Spring and Netflix: the aftermath - Trifork Blog","isPartOf":{"@id":"https:\/\/trifork.nl\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#primaryimage"},"image":{"@id":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#primaryimage"},"thumbnailUrl":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png","datePublished":"2015-11-26T14:41:58+00:00","author":{"@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/265bd41e503f7176742258a927de598b"},"breadcrumb":{"@id":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#primaryimage","url":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png","contentUrl":"https:\/\/trifork.nl\/articles\/wp-content\/uploads\/sites\/3\/2015\/11\/arch1-300x226.png"},{"@type":"BreadcrumbList","@id":"https:\/\/trifork.nl\/blog\/booting-your-microservices-architecture-with-spring-and-netflix-the-aftermatch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/trifork.nl\/blog\/"},{"@type":"ListItem","position":2,"name":"Booting your Microservices Architecture with Spring and Netflix: the aftermath"}]},{"@type":"WebSite","@id":"https:\/\/trifork.nl\/blog\/#website","url":"https:\/\/trifork.nl\/blog\/","name":"Trifork Blog","description":"Keep updated on the technical solutions Trifork is working on!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/trifork.nl\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/265bd41e503f7176742258a927de598b","name":"Joris Kuipers","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9ab8da0d60582bad84342d4602d23dbd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9ab8da0d60582bad84342d4602d23dbd?s=96&d=mm&r=g","caption":"Joris Kuipers"},"sameAs":["http:\/\/www.trifork.nl"],"url":"https:\/\/trifork.nl\/blog\/author\/jorisk\/"}]}},"_links":{"self":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/14485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/users\/62"}],"replies":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/comments?post=14485"}],"version-history":[{"count":0,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/14485\/revisions"}],"wp:attachment":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/media?parent=14485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/categories?post=14485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/tags?post=14485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}